I am working with strongly-typed DataSets, hoping to save some boxing and unboxing costs.
In the DataBase table that I am working with, there are columns that can be null.
The strongly-typed DataSet class generated by using the VS Designer exposes the columns in a row via the DataSet.DataRow class properties. The problem is, that for null values, the get methods of the properties merely throw exceptions when they try to parse from a value equal to System.DBNull.
I would think that the get method in the property for database columns that map to reference types like strings and dates should return null (or maybe string.Empty). For value types, an exception seems reasonable.
I would like to revise the properties in the DataRow class to return some kind of dummy value when the actual value is System.DBNull. The problem that I am having is that VS.NET regenerates the .cs file if I make and save any changes in the .xsd file and overwrite changes that I have made. VS.NET does tell me that the .cs file has been modified outside the Source Editor and asks me if I want to reload it, but it would be better if VS.NET didn't modify it at all.
Is there a way to turn this behavior off?
Is customizing the DataSet.DataRow class properties advisable or should I always index into the value in the row first and make sure it isn't System.DBNull first? That seems awkward.
David S. Alexander
Kettley Publishing
20271 SW Birch Street, 2nd Floor
Newport Beach, CA 92660-1752