Tuesday, December 05, 2006

Typed datasets and VS 2005

Recently I had to use typed datasets in a project for the first time. I always preferred using custom entity objects but due to time constraints there was no option on this one. One thing I don't like about the new typed datasets is that it combines the data access code with the data itself if you drag a table from the server explorer into the dataset it creates the connection and the table adapter in the dataset itself, so much for tiered architecture. So I decided the best thing to do is to delete the table adapter from the dataset and just use it as a container.

Another issue that you have to keep in mind when you use typed datasets is that sooner or later you are going to create datasets that share tables among them. If you create the table in each and every dataset its going to create a maintenance nightmare. A better option is to add a xml schema to your project and define all the tables there and include that schema in each of your datasets using the xs:include element. This way you only have to change one file if your table definitions change.

One disadvantage of the above method is that you cannot define keys in the schema, you have to add the keys to each and every dataset. Another minor issue is that the graphical dataset designer gets a bit messed up with this approach. Lets hope the next version of VS comes with a better dataset designer.

No comments: