I have just become began with development using Visual Studio (though this is often seen as an more language-generic question), and want done design solutions concerning how to appropriate relate a Database Entity/Table by having an Class in-code.
Presently, I produce a class who's characteristics or iVars directly match the fields within an Entity.
After I arrived at fetching all 'Customers from the Table' for instance, I operate a Choose all statement from the database as well as for each result-row came back, I instantiate a brand new class Object where I personally use the Class' default constructor to create the instance variables. (I truly wish there is a technique like PHP's mysql-fetch-object()?)
I'm able to adding all these objects to express, a listing(of Customer) and give it back.
This does not appear like the easiest method to get it done. Basically would alter the Database schema, I'd need to reflect individuals alterations in the course also.
It may sound like what you are searching for is definitely an "object-relational mapper", for example Entity Framework or NHibernate.
Entity Framework is Microsoft's solution, and it is area of the .Internet framework (though for that latest version (4.1), you will need to download that individually). NHibernate is really a third-party library. Both should have the ability to assist with what you are attempting to do.