Link to home
Start Free TrialLog in
Avatar of jfz139
jfz139

asked on

How to design C# class and access to SqlServer.

Hi,

I am designing and developing a small new proejct in C# and SqlServer.
Since I am very new to C# and SqlServer (I used to work with Java),
I have the following questions:
1.Is it a good practice to create a class for each table in sqlserver?
2.If not, how to do it in a good way? Any good sample code?
3.Also, any sample code on C# to access SqlServer DB?

Thanks a lot.

Jennifer
ASKER CERTIFIED SOLUTION
Avatar of john_dobson
john_dobson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
in general, the basic concept behind building classes in your application, it to have a Class for each functional OBJECT the your app will manipulate.  That MAY mean one class per table, but if you have objects that trule have data that span several tables (this depends on how you database is structure, and on the particulars of the application), then you might have one class using data from SEVERAL tables, or even several classes using non-overlapping data from a SINGLE table.

There is nbo single, hard-and-fast rule.  For a VERY simple application, it would TYPICALLY be the case that you would have one class per table, but this would be a fairly simple structure.

AW
Avatar of jfz139
jfz139

ASKER

John and Arthur,

Thank you both for helping me. I think both of you answered my question.
And I would like to give both some pts. Since I can accept only one answer,
I am going to accept John's answer. Sorry about it.

Thanks a lot.

Jennifer