views:

41

answers:

1

Hi,

Assumption - For a simple app I have with only a few tables & I plan to stay simple and use DataSet for my data access as well as domain layer. In other way, in this small application, I won't create separate classes but rather just use the DataSet directly.

Question - Does anyone have any code/patterns/suggestions re how best to do this approach?

For example, how to add helper methods (that'll be used multiple times) that I can use on the dataset that understand the data structure. Would a pattern such as extending the DataSet class to my own, and then putting these methods in here, be a good approach).

Thanks

+1  A: 

Strongly typed DataSet.

A typed DataSet is a class that derives from a DataSet. As such, it inherits all the methods, events, and properties of a DataSet. Additionally, a typed DataSet provides strongly typed methods, events, and properties. This means you can access tables and columns by name, instead of using collection-based methods. Aside from the improved readability of the code, a typed DataSet also allows the Visual Studio .NET code editor to automatically complete lines as you type.

Additionally, the strongly typed DataSet provides access to values as the correct type at compile time. With a strongly typed DataSet, type mismatch errors are caught when the code is compiled rather than at run time.

The biggest plus is that you can use DateSet Designer and hence create fairly quickly one and also add methods to get and update data. I think you're familiar with that but here's a link if you need Walkthrough: Creating a Dataset with the Dataset Designer

And when it comes to design patterns, by using DateSet you can simulate Table Data Gateway and Table Module design patterns (from Martin Fowler's Pattern of Enterprise Application Architecture book). You can find more information on those design patterns on his web site.

Greg