DataSet Extension Methods

The following extension methods are defined for types related to the DataSet type. Use the methods in conjunction with the DataSet extension methods first shipped with .NET 3.5.

DataRow specific

  • TValue Value<TValue>(string columnName).
    Gets the value of the column with the name columnName specified from the DataRow specified, casted to the type TValue. If the value is DBNull.Value, null / Nothing will be returned, if TValue is a nullable value type or a reference type. If the value is DBNull.Value and TValue is a non-nullable value type, the default value for TValue will be returned. Use this method instead of the extension method Field<TValue> Microsoft shipped with .NET 3.5/4.0 if you don't want to receive cast exceptions. Conversions are done using Convert.ChangeType if 'is' fails.

Last edited Nov 27, 2010 at 12:29 PM by SolutionsDesign, version 2

Comments

No comments yet.