Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database CRUD Design Pattern (using .NET)

Status
Not open for further replies.

dragonwell

Programmer
Oct 21, 2002
863
0
0
US
Essentially I run into the same situation over and over. I need to crud (create, read, update, delete) data into/out of a database structure using asp.net web pages. I can bang out the "read one", "list" and "insert/update" stored procedures without any problem - I need to find a way to translate these sprocs into classes that can be manipulated by the client app and are abstract enough that they will be easily maintainable.

I'm looking for a basic crud design pattern, taking advantage of the .net Data class. I have looked in the the GoF Command as well as the Engine-Collection-Class pattern from MS. Has anyone come used these (or variations of) these patterns in a .net web application? And would you care to comment or direct to a place where I can see some sample code?

Thanks,
David
 
I haven't seen any design patterns that are specific to this problem.

However, ADO.Net classes are a great tool for this type of work. The hardest thing you would have to do is set up the structure for strongly typed DataSets. It's actually pretty easy, it just takes a little work.

Using the DataAdapter you can generate a DataSet from you stored procs. The desing pattens that Microsoft implemented in ADO.Net allow, in fact require that you, completly control the select and update scenarios.

One of the down sides with the approach is that you have to control the update sequence. DataSets and the DataAdapter can only update one table at a time. The DataAdapter Command objects allow you to use your stored procedures.

The other thing you may want to watch for is concurancy. TimeStamps or RowVersion will help with locking and reporting changed rows in a disconnected environment.

If you don't want to use the DataSet and DataAdapter for updates, we sue the DataSet for the Web pages and send the data between the middle tier business and data managers as XML. The reason we use DataSets in the front-end is that they provide very good DataSource and DataBinding capability. Yes - the data bound control actually work.

I have used both with great success. The best book I've found on the subject is Microsoft ADO.NET (Core Reference)
by David Sceppa

Hope this helps,

fellthor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top