Redigeeri

Jagamisviis:


DataRowExtensions.Field Method

Definition

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

row
DataRow

The input DataRow, which acts as the this instance for the extension method.

column
DataColumn

The input DataColumn object that specifies the column to return the value of.

Returns

T

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.

The column specified by column does not occur in the DataTable that the DataRow is a part of.

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

row
DataRow

The input DataRow, which acts as the this instance for the extension method.

columnIndex
Int32

The column index.

Returns

T

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.

The column specified by ordinal does not exist in the DataTable that the DataRow is a part of.

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

row
DataRow

The input DataRow, which acts as the this instance for the extension method.

columnName
String

The name of the column to return the value of.

Returns

T

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.

The column specified by columnName does not occur in the DataTable that the DataRow is a part of.

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

row
DataRow

The input DataRow, which acts as the this instance for the extension method.

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

T

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.

The column specified by column does not exist in the DataTable that the DataRow is a part of.

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

row
DataRow

The input DataRow, which acts as the this instance for the extension method.

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

T

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.

The column specified by ordinal does not exist in the DataTable that the DataRow is a part of.

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

row
DataRow

The input DataRow, which acts as the this instance for the extension method.

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

T

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.

The column specified by columnName does not exist in the DataTable that the DataRow is a part of.

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