DbExtensions.GetValueOrDefault 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
GetValueOrDefault<TValue>(IDataRecord, Int32, TValue) |
如果不是 DBNull ,則傳回值, 否則會傳回預設 (TValue) 。 |
GetValueOrDefault<TValue>(IDataRecord, String, TValue) |
如果不是 DBNull ,則傳回值, 否則會傳回預設 (TValue) 。 |
GetValueOrDefault<TValue>(IDataRecord, Int32, TValue)
如果不是 DBNull ,則傳回值, 否則會傳回預設 (TValue) 。
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
類型參數
- TValue
要要求之值的型別。
參數
- record
- IDataRecord
要從中擷取值的記錄。
- ordinal
- Int32
fieldname 的序數。
- default
- TValue
如果位置中的值為 ,則預設值為 DBNull 。
傳回
TValue
所要求型別的指定值或預設值。
例外狀況
適用於
GetValueOrDefault<TValue>(IDataRecord, String, TValue)
如果不是 DBNull ,則傳回值, 否則會傳回預設 (TValue) 。
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
類型參數
- TValue
要要求之值的型別。
參數
- record
- IDataRecord
要從中擷取值的記錄。
- fieldName
- String
要擷取的欄位名稱。
- default
- TValue
如果位置中的值為 ,則預設值為 DBNull 。
傳回
TValue
所要求型別的指定值或預設值。
例外狀況
備註
如果指定的 不存在,此函式會擲回。