共用方式為


DbExtensions.GetValueOrDefaultAsync 方法

定義

多載

GetValueOrDefaultAsync<TValue>(DbDataReader, Int32, TValue)

如果不是 DBNull ,則傳回值,否則 (TValue) 預設值

GetValueOrDefaultAsync<TValue>(DbDataReader, String, TValue)

如果不是 DBNull ,則傳回值,否則 (TValue) 預設值

GetValueOrDefaultAsync<TValue>(DbDataReader, Int32, TValue)

如果不是 DBNull ,則傳回值,否則 (TValue) 預設值

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

類型參數

TValue

要要求之值的型別。

參數

record
DbDataReader

要從中擷取值的記錄。

ordinal
Int32

fieldname 的序數。

default
TValue

如果位置 DBNull 中的值為 ,則為預設值。

傳回

Task<TValue>

所要求類型的指定值或預設值。

例外狀況

適用於

GetValueOrDefaultAsync<TValue>(DbDataReader, String, TValue)

如果不是 DBNull ,則傳回值,否則 (TValue) 預設值

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

類型參數

TValue

要要求之值的型別。

參數

record
DbDataReader

要從中擷取值的記錄。

fieldName
String

要擷取的欄位名稱。

default
TValue

如果位置 DBNull 中的值為 ,則為預設值。

傳回

Task<TValue>

所要求類型的指定值或預設值。

例外狀況

備註

如果指定的 不存在,這個函式會擲回 。

適用於