Class design when working with dataset

Posted by MC on Stack Overflow See other posts from Stack Overflow or by MC
Published on 2010-04-26T15:05:50Z Indexed on 2010/04/26 15:13 UTC
Read the original article Hit count: 235

If you have to retrieve data from a database and bring this dataset to the client, and then allow the user to manipulate the data in various ways before updating the database again, what is a good class design for this if the data tables will not have a 1:1 relationship with the class objects?

Here are some I came up with:

  1. Just manipulate the DataSet itself on the client and then send it back to the database as is. This will work though obviously the code will be very dirty and not well-structured.

  2. Same as #1, but wrap the dataset code around classes. What I mean is that you may have a class that takes a dataset or a datatable in its constructor, and then provides public methods and properties to simplify the code. Inside these methods and properties it will be reading or manipulating the dataset. To update the database afterwards will be easy because you already have the updated dataset.

  3. Get rid of the dataset entirely on the client, convert to objects, then convert back to a dataset when needing to update the database.

Is there any good resources where I can find information on this?

© Stack Overflow or respective owner

Related posts about class-design

Related posts about database