I, too, have been using this for quite a while now and it does save a lot of code writing. I have developed a usage pattern that seems to work, although I'm not sure if it's such a great pattern in terms of maintenence. I usually design classes representing
a persisted object to pretty much replicate the schema of a table, and I give the classes methods such as Load, Save and a static List method. Each method has a corresponding stored procedure. So, within my Load method, for example, I set up an array of Output
parameters, call SqlHelper.ExecuteNonQuery(...) and then set my object's properties to the the values of the output params. If I need to make a change to the table schema, I then have to rework the code that builds the parameters, and usually have to change
all the indices of the params array to make it match the sproc. I have thought about using the cached parameters functionality, but then - since the parameters are dynamically determined, I lose the ability to assign their values to class members explicitly,
don't I? The other option is using DataSets instead of objects with properties that match columns. But that seems like going back to the old RecordSet("columnName") days - I really like having strongly typed properties instead. Comments? Regards, David
If you use a typed dataset instead of plain-vanilla dataset, there is strong typing of fields. It will "feel" much like you custom data interface classes since the typed dataset essentially is just a hierarchical series of classes that mimic the underlying
database structures. Object instances are defined for rows, with typed properties for the columns. Basically the same thing you are coding by hand now from the sound of it...
This is good idea. I did it in this way sometime, but didn't think in this way. But, do you suggest that with using DataSet associated with DataTable, DataColumn and Rows could replace the custom object created by ourselves in BLL, somehow like using the MS
DAL in different applications to replace the own developed DAL that is probably different for each application? Or, how about to address the question: when it is suitable to use strong typed DataSet and when to use custom objects?
MCAD.NET (C#)
MCP on: SQL Server 2k Design&Iimplementation, Web Development (VI 6.0) and VB 5.0
dave_m
Member
65 Points
13 Posts
class design w/DAAB
Jul 18, 2003 04:09 PM|LINK
krome
Member
190 Points
38 Posts
Re: class design w/DAAB
Jul 19, 2003 11:14 PM|LINK
MCSD, MCDBA, MCAD, CIC
ghan
Participant
1440 Points
288 Posts
Re: class design w/DAAB
Aug 07, 2003 04:37 PM|LINK
MCP on: SQL Server 2k Design&Iimplementation, Web Development (VI 6.0) and VB 5.0