views:

1155

answers:

4

When using strongly typed dataSets in Visual Studio 2005/2008, if the underlying database schema changes, the only practical way to refresh is to delete the dataset and recreate it from scratch. This is OK unless I need to customize the dataset.

Customizing by extending the partial dataset class allows customizations to be retained, but then a simple FillBy() again becomes a long sequence of SQL.

Is there any way to resynchronize a dataset with the database schema without losing dataset customizations?

+2  A: 

If you are just making a simple change like adding a field to a table, then I right click on the table and click configure. Go through the wizard again adding the new field, (or even replacing the select with select *) and it adds the field to the table and syncs up all the queries that you've built. I've had tables with about 10 different custom queries and when I reconfigure the table the queries all updated properly.

bendewey
+2  A: 

Because typed datasets use generated nested classes, customizations will often be lost. What I do is generate the typed dataset, and then mark several classes as partial. Then I create separate files containing a duplicate nested class structure (also marked partial).

This way I can regenerate my data set and the only update I have to do is to go back and make them partial again. My customizations are kept in separate files.

Geoff Cox
+1  A: 

Typed Datasets are evil. LINQ to SQL is what typed datasets should have been, so I like to think of it as Typed Datasets 3.0. I hope when they fold L2S into the Entity Framework they retain what makes L2S so good.

sliderhouserules
"Typed Datasets are evil" doesn't tell us very much. What don't you like about them?
Kyralessa
A: 

I've been using typed datasets quite successfully in a number of web and windows projects. There was a bit of discovery in the beginning - learning all the quirks of the dataset designer and how to extend the dataset to provide more flexible connection configurations. But once you get past that, generating a data access layer will be quick work.

Patrick Manderson