Edytuj

Udostępnij za pośrednictwem


DbExtensions.GetValueOrDefault Method

Definition

Overloads

GetValueOrDefault<TValue>(IDataRecord, Int32, TValue)

Returns a value if it is not DBNull, default(TValue) otherwise.

GetValueOrDefault<TValue>(IDataRecord, String, TValue)

Returns a value if it is not DBNull, default(TValue) otherwise.

GetValueOrDefault<TValue>(IDataRecord, Int32, TValue)

Returns a value if it is not DBNull, default(TValue) otherwise.

public static TValue GetValueOrDefault<TValue> (this System.Data.IDataRecord record, int ordinal, TValue default = default);
static member GetValueOrDefault : System.Data.IDataRecord * int * 'Value -> 'Value
<Extension()>
Public Function GetValueOrDefault(Of TValue) (record As IDataRecord, ordinal As Integer, Optional default As TValue = Nothing) As TValue

Type Parameters

TValue

The type of the value to request.

Parameters

record
IDataRecord

The record from which to retrieve the value.

ordinal
Int32

The ordinal of the fieldname.

default
TValue

The default value if value in position is DBNull.

Returns

TValue

Either the given value or the default for the requested type.

Exceptions

Applies to

GetValueOrDefault<TValue>(IDataRecord, String, TValue)

Returns a value if it is not DBNull, default(TValue) otherwise.

public static TValue GetValueOrDefault<TValue> (this System.Data.IDataRecord record, string fieldName, TValue default = default);
static member GetValueOrDefault : System.Data.IDataRecord * string * 'Value -> 'Value
<Extension()>
Public Function GetValueOrDefault(Of TValue) (record As IDataRecord, fieldName As String, Optional default As TValue = Nothing) As TValue

Type Parameters

TValue

The type of the value to request.

Parameters

record
IDataRecord

The record from which to retrieve the value.

fieldName
String

The name of the field to retrieve.

default
TValue

The default value if value in position is DBNull.

Returns

TValue

Either the given value or the default for the requested type.

Exceptions

Remarks

This function throws if the given does not exist.

Applies to