DataRowExtensions.Field Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides strongly-typed access to each of the column values in the DataRow.
Overloads
Field<T>(DataRow, DataColumn) |
Provides strongly-typed access to each of the column values in the specified row. The Field<T>(DataRow, DataColumn) method also supports nullable types. |
Field<T>(DataRow, Int32) |
Provides strongly-typed access to each of the column values in the specified row. The Field<T>(DataRow, Int32) method also supports nullable types. |
Field<T>(DataRow, String) |
Provides strongly-typed access to each of the column values in the specified row. The Field<T>(DataRow, String) method also supports nullable types. |
Field<T>(DataRow, DataColumn, DataRowVersion) |
Provides strongly-typed access to each of the column values in the specified row. The Field<T>(DataRow, DataColumn, DataRowVersion) method also supports nullable types. |
Field<T>(DataRow, Int32, DataRowVersion) |
Provides strongly-typed access to each of the column values in the specified row. The Field<T>(DataRow, Int32, DataRowVersion) method also supports nullable types. |
Field<T>(DataRow, String, DataRowVersion) |
Provides strongly-typed access to each of the column values in the specified row. The Field<T>(DataRow, String, DataRowVersion) method also supports nullable types. |
Field<T>(DataRow, DataColumn)
- Source:
- DataRowExtensions.cs
- Source:
- DataRowExtensions.cs
- Source:
- DataRowExtensions.cs
Provides strongly-typed access to each of the column values in the specified row. The Field<T>(DataRow, DataColumn) method also supports nullable types.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static T Field(System::Data::DataRow ^ row, System::Data::DataColumn ^ column);
public static T? Field<T> (this System.Data.DataRow row, System.Data.DataColumn column);
public static T Field<T> (this System.Data.DataRow row, System.Data.DataColumn column);
static member Field : System.Data.DataRow * System.Data.DataColumn -> 'T
<Extension()>
Public Function Field(Of T) (row As DataRow, column As DataColumn) As T
Type Parameters
- T
A generic parameter that specifies the return type of the column.
Parameters
- column
- DataColumn
The input DataColumn object that specifies the column to return the value of.
Returns
The value, of type T
, of the DataColumn specified by column
.
Exceptions
The value type of the underlying column could not be cast to the type specified by the generic parameter, T
.
A null value was assigned to a non-nullable type.
Remarks
The DataSet class represents null values with the Value instance of the DBNull class. A Language-Integrated Query (LINQ) expression that accessed a column with a null value would generate a InvalidCastException at run time. Additionally, DataSet and DataTable do not support nullable types. The Field method provides support for accessing columns as nullable types. If the underlying value in the DataSet is DBNull.Value, the returned nullable type will have a value of null.
If the value of the specified DataColumn is DBNull.Value and T
is a reference type or nullable type, the return type will be null. The Field method will not return DBNull.Value.
The Field method does not perform type conversions. If type conversion is required, you should first obtain the column value by using the Field method. The column value should then be converted to another type.
Applies to
Field<T>(DataRow, Int32)
- Source:
- DataRowExtensions.cs
- Source:
- DataRowExtensions.cs
- Source:
- DataRowExtensions.cs
Provides strongly-typed access to each of the column values in the specified row. The Field<T>(DataRow, Int32) method also supports nullable types.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static T Field(System::Data::DataRow ^ row, int columnIndex);
public static T? Field<T> (this System.Data.DataRow row, int columnIndex);
public static T Field<T> (this System.Data.DataRow row, int columnIndex);
static member Field : System.Data.DataRow * int -> 'T
<Extension()>
Public Function Field(Of T) (row As DataRow, columnIndex As Integer) As T
Type Parameters
- T
A generic parameter that specifies the return type of the column.
Parameters
- columnIndex
- Int32
The column index.
Returns
The value, of type T
, of the DataColumn specified by columnIndex
.
Exceptions
The value type of the underlying column could not be cast to the type specified by the generic parameter, T
.
A null value was assigned to a non-nullable type.
Remarks
The DataSet class represents null values with the Value instance of the DBNull class. A Language-Integrated Query (LINQ) expression that accessed a column with a null value would generate a InvalidCastException at run time. Additionally, DataSet doesn't support nullable types. The Field method provides support for accessing columns as nullable types. If the underlying value in the DataSet is DBNull.Value, the returned nullable type will have a value of null.
If the value of the specified DataColumn is null and T
is a reference type or nullable type, then the return type will be null. The Field method will not return DBNull.Value.
The Field method does not perform type conversions. If type conversion is required, you should first obtain the column value by using the Field method. The column value should then be converted to another type.
Applies to
Field<T>(DataRow, String)
- Source:
- DataRowExtensions.cs
- Source:
- DataRowExtensions.cs
- Source:
- DataRowExtensions.cs
Provides strongly-typed access to each of the column values in the specified row. The Field<T>(DataRow, String) method also supports nullable types.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static T Field(System::Data::DataRow ^ row, System::String ^ columnName);
public static T? Field<T> (this System.Data.DataRow row, string columnName);
public static T Field<T> (this System.Data.DataRow row, string columnName);
static member Field : System.Data.DataRow * string -> 'T
<Extension()>
Public Function Field(Of T) (row As DataRow, columnName As String) As T
Type Parameters
- T
A generic parameter that specifies the return type of the column.
Parameters
- columnName
- String
The name of the column to return the value of.
Returns
The value, of type T
, of the DataColumn specified by columnName
.
Exceptions
The value type of the underlying column could not be cast to the type specified by the generic parameter, T
.
A null
value was assigned to a non-nullable type.
Remarks
The DataSet class represents null values with the Value instance of the DBNull class. A Language-Integrated Query (LINQ) expression that accessed a column with a null value would generate a InvalidCastException at run time. Additionally, DataSet and DataTable do not support nullable types. The Field method provides support for accessing columns as nullable types. If the underlying value in the DataSet is DBNull.Value, the returned nullable type will have a value of null.
If the value of the specified DataColumn is null and T
is a reference type or nullable type, the return type will be null. The Field method will not return DBNull.Value.
The Field method does not perform type conversions. If type conversion is required, you should first obtain the column value by using the Field method. The column value should then be converted to another type.
Applies to
Field<T>(DataRow, DataColumn, DataRowVersion)
- Source:
- DataRowExtensions.cs
- Source:
- DataRowExtensions.cs
- Source:
- DataRowExtensions.cs
Provides strongly-typed access to each of the column values in the specified row. The Field<T>(DataRow, DataColumn, DataRowVersion) method also supports nullable types.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static T Field(System::Data::DataRow ^ row, System::Data::DataColumn ^ column, System::Data::DataRowVersion version);
public static T? Field<T> (this System.Data.DataRow row, System.Data.DataColumn column, System.Data.DataRowVersion version);
public static T Field<T> (this System.Data.DataRow row, System.Data.DataColumn column, System.Data.DataRowVersion version);
static member Field : System.Data.DataRow * System.Data.DataColumn * System.Data.DataRowVersion -> 'T
<Extension()>
Public Function Field(Of T) (row As DataRow, column As DataColumn, version As DataRowVersion) As T
Type Parameters
- T
A generic parameter that specifies the return type of the column.
Parameters
- column
- DataColumn
The input DataColumn object that specifies the column to return the value of.
- version
- DataRowVersion
A DataRowVersion enumeration that specifies the version of the column value to return, such as Current
or Original
version.
Returns
The value, of type T
, of the DataColumn specified by column
and version
.
Exceptions
The value type of the underlying column could not be cast to the type specified by the generic parameter, T
.
A null value was assigned to a non-nullable type.
Remarks
The DataSet class represents null values with the Value instance of the DBNull class. A Language-Integrated Query (LINQ) expression that accessed a column with a null value would generate a InvalidCastException at run time. Additionally, DataSet doesn't support nullable types. The Field method provides support for accessing columns as nullable types. If the underlying value in the DataSet is DBNull.Value, the returned nullable type will have a value of null.
If the value of the specified DataColumn is null and T
is a reference type or nullable type, then the return type will be null. The Field method will not return DBNull.Value.
The Field method does not perform type conversions. If type conversion is required, you should first obtain the column value by using the Field method. The column value should then be converted to another type.
Applies to
Field<T>(DataRow, Int32, DataRowVersion)
- Source:
- DataRowExtensions.cs
- Source:
- DataRowExtensions.cs
- Source:
- DataRowExtensions.cs
Provides strongly-typed access to each of the column values in the specified row. The Field<T>(DataRow, Int32, DataRowVersion) method also supports nullable types.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static T Field(System::Data::DataRow ^ row, int columnIndex, System::Data::DataRowVersion version);
public static T? Field<T> (this System.Data.DataRow row, int columnIndex, System.Data.DataRowVersion version);
public static T Field<T> (this System.Data.DataRow row, int columnIndex, System.Data.DataRowVersion version);
static member Field : System.Data.DataRow * int * System.Data.DataRowVersion -> 'T
<Extension()>
Public Function Field(Of T) (row As DataRow, columnIndex As Integer, version As DataRowVersion) As T
Type Parameters
- T
A generic parameter that specifies the return type of the column.
Parameters
- columnIndex
- Int32
The zero-based ordinal of the column to return the value of.
- version
- DataRowVersion
A DataRowVersion enumeration that specifies the version of the column value to return, such as Current
or Original
version.
Returns
The value, of type T
, of the DataColumn specified by ordinal
and version
.
Exceptions
The value type of the underlying column could not be cast to the type specified by the generic parameter, T
.
A null value was assigned to a non-nullable type.
Remarks
The DataSet class represents null values with the Value instance of the DBNull class. A Language-Integrated Query (LINQ) expression that accessed a column with a null value would generate a InvalidCastException at run time. Additionally, DataSet doesn't support nullable types. The Field method provides support for accessing columns as nullable types. If the underlying value in the DataSet is DBNull.Value, the returned nullable type will have a value of null.
If the value of the specified DataColumn is null and T
is a reference type or nullable type, then the return type will be null. The Field method will not return DBNull.Value.
The Field method does not perform type conversions. If type conversion is required, you should first obtain the column value by using the Field method. The column value should then be converted to another type.
Applies to
Field<T>(DataRow, String, DataRowVersion)
- Source:
- DataRowExtensions.cs
- Source:
- DataRowExtensions.cs
- Source:
- DataRowExtensions.cs
Provides strongly-typed access to each of the column values in the specified row. The Field<T>(DataRow, String, DataRowVersion) method also supports nullable types.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static T Field(System::Data::DataRow ^ row, System::String ^ columnName, System::Data::DataRowVersion version);
public static T? Field<T> (this System.Data.DataRow row, string columnName, System.Data.DataRowVersion version);
public static T Field<T> (this System.Data.DataRow row, string columnName, System.Data.DataRowVersion version);
static member Field : System.Data.DataRow * string * System.Data.DataRowVersion -> 'T
<Extension()>
Public Function Field(Of T) (row As DataRow, columnName As String, version As DataRowVersion) As T
Type Parameters
- T
A generic parameter that specifies the return type of the column.
Parameters
- columnName
- String
The name of the column to return the value of.
- version
- DataRowVersion
A DataRowVersion enumeration that specifies the version of the column value to return, such as Current
or Original
version.
Returns
The value, of type T
, of the DataColumn specified by columnName
and version
.
Exceptions
The value type of the underlying column could not be cast to the type specified by the generic parameter, T
.
A null value was assigned to a non-nullable type.
Remarks
The DataSet class represents null values with the Value instance of the DBNull class. A Language-Integrated Query (LINQ) expression that accessed a column with a null value would generate a InvalidCastException at run time. Additionally, DataSet doesn't support nullable types. The Field method provides support for accessing columns as nullable types. If the underlying value in the DataSet is DBNull.Value, the returned nullable type will have a value of null.
If the value of the specified DataColumn is null and T
is a reference type or nullable type, then the return type will be null. The Field method will not return DBNull.Value.
The Field method does not perform type conversions. If type conversion is required, you should first obtain the column value by using the Field method. The column value should then be converted to another type.