DbExtensions.GetValueOrDefault 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.
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
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
Either the given value or the default for the requested type.
Exceptions
Remarks
This function throws if the given does not exist.