In the last (and first) post of this series we discussed how to create a typed dataset. Now that we have our dataset we need to see how to use it.

But before we go into the details, I want to explain something that I stumbled upon in my research. There is a serious bug in the implementation of the dataset generator. It effects retrieving and manipulating childrows when you are dealing with related tables.

After a great deal of hair pulling, self doubt, and serious coffee consumption, I finally found a series of blog posts that ended up leading me here. The bug has been confirmed and will be released: “thanks again for reporting this. We fixed this problem and the fix will be available in the next Visual Studio release.”

Description
When you create a typed DataSet using the class-designer of VS.NET with a parent- and a child-table, a method is generated on the parentrow-class which should return the childrows. This method uses DataRow.GetChilds with the name of the relationship. This method returns a parentrow-array instead of a childrow-array. The generated method casts it to a childrow-array and thus causes a InvalidCastException.
This bug reduces some of the functionality of the typed dataset in production applications. There is a workaround, but it is a simple kludge, and the end result is that you cannot easily work with related data.
 
Ok, with that said, lets continue on with the series. Next post in this series will take us back into the thick of it. There is still a huge benefit to using typed datasets, just sad that this bug caused such an unfortunate loss of some of that functionality.
 
Cheers,
 
Robert Porter

 
Comments are closed.