Code for chapter 7: Northwind System
Code for chapter 7: Northwind System
Method SeekUsingCountry has been updated. The old code can be found in the method LegacySeekUsingCountry.
Errata Title: Invalid Cast Error using Select method of DataTable with typed DataRow array
Problem
The release version of VS .NET introduced a new bug that gives you an invalid cast exception when you try to set the Select method to a typed DataRow array. The Select() method generates an Invalid Cast error when used with an array of typed DataRows.
Resolution
Microsoft confirmed that this is a bug. They said this will be fixed in the service pack 1 for Visual Studio .NET. There was no hot fix available at the time of this publication.
Reason for problem
The Select method of the DataTable was updated to leverage any existing indexes. This new feature can improve performance thirty-fold. This new feature was introduced shortly prior to ship data, causing support for the typed DataRow in the Select() method to fail.
Workaround
Use generic DataRow array. You can filter using the Select() statement, and still take advantage of strong typing. To do this, I am forcing a cast on the DataRow in the generic DataRow array to the typed DataRow, as I loop through it – that way I can use strong typing.
Text Updates
The text discusses how you can take advantage of typed DataTables using the Select() statement. Now that this is no longer supported, the code is updated to reflect the workaround.
|