tags:

views:

185

answers:

5

Hi, I am designing an application where I want to reduce the burden on the developers for future for development. In this I have list of classes e.g-"User,Account,Permission and etc" now these classes are associated to the table in the database with the name of the class same as data table. I want my business layer to be robust so that in future whenever I add any more column to the data table I don't have to rewrite insert update and delete command just adding property to the class should do the job.

Any Idea how to do this?

+4  A: 

What you are looking for is probably an ORM (Object-Relational Mapping) framework. The most popular ones for .NET includes Linq-to-SQL (or Entity Framework), NHibernate nad ActiveRecord. Using an ORM is considered a best practice for achieving a maintainable and robust Data Access Layer.

See a list of frameworks here.

JacobE
how can I do this any Link or something that can help?
Vinay Pandey
there are tons of examples on the net... Google is the developer's best friend
JacobE
@JacobE: I wish Google were female! :P
Cerebrus
+1  A: 

What you're probably looking for is to implement an Object Relational Mapping (ORM) solution. Many ORM solutions help you maintain table and entity definitions and also create the appropriate queries for you.

Popular ORMs for the .Net Framework include NHibernate, the ADO Entity Framework and LINQ to SQL. Otherwise you could consider mapping your data model using templates (like using Codesmith, or the Net Tiers templates).

You could check out the answers to this question for more advice on picking an ORM solution, or you can just browse some ORM related questions tagged here.

RobS
A: 

I think what you are looking for is a Data Transfer Object. Here's an article that explains more about the DTO pattern.

Additionally, here's an article that explains how to implement a DTO with a Dataset. In your case, the Dataset would be replaced with your own Datalayer.

Cerebrus
A: 

Picking an ORM solution is one way, additionally i would mention the upcoming Oslo.

For a more "traditional" approach i would take a look of Data Abstract.

ErvinS
A: 

Quite interesting reading about this topic is the Persitence Patterns article. It explains the most common and basic design patterns used for the Data Access. Also it discusses when the concrete DP might be more suitable than the other.

parapet