Share via


QueryableExtensions.AverageAsync 方法 (IQueryable<Nullable<Single>>)

[此頁面專屬於 Entity Framework 第 6 版。最新版本可從 'Entity Framework' NuGet 套件取得。如需 Entity Framework 的詳細資訊,請參閱 msdn.com/data/ef。]

非同步計算可為 Null 之 Single 值序列的平均值。

命名空間:  System.Data.Entity
組件:  EntityFramework (在 EntityFramework.dll 中)

語法

'宣告
<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")> _
<ExtensionAttribute> _
Public Shared Function AverageAsync ( _
    source As IQueryable(Of Nullable(Of Single)) _
) As Task(Of Nullable(Of Single))
'用途
Dim source As IQueryable(Of Nullable(Of Single))
Dim returnValue As Task(Of Nullable(Of Single))

returnValue = source.AverageAsync()
[SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public static Task<Nullable<float>> AverageAsync(
    this IQueryable<Nullable<float>> source
)
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1006:DoNotNestGenericTypesInMemberSignatures")]
[ExtensionAttribute]
public:
static Task<Nullable<float>>^ AverageAsync(
    IQueryable<Nullable<float>>^ source
)
[<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")>]
static member AverageAsync : 
        source:IQueryable<Nullable<float32>> -> Task<Nullable<float32>> 
public static function AverageAsync(
    source : IQueryable<Nullable<float>>
) : Task<Nullable<float>>

參數

傳回值

類型:System.Threading.Tasks.Task<Nullable<Single>>
表示非同步作業的工作。工作結果包含值序列的平均值。

使用注意事項

在 Visual Basic 和 C# 中,您可以在任何 IQueryable<Nullable<Single>> 類型物件中呼叫這個方法以做為執行個體。使用執行個體方法語法呼叫這個方法時,請省略第一個參數。如需詳細資訊,請參閱 https://msdn.microsoft.com/zh-tw/library/bb384936(v=vs.113)https://msdn.microsoft.com/zh-tw/library/bb383977(v=vs.113)

例外狀況

例外狀況 條件
ArgumentNullException

source 為 null。

InvalidOperationException

source 不會實作 IDbAsyncQueryProvider

備註

不支援相同內容執行個體上的多個作用中作業。 使用 'await' 確保在此內容上呼叫另一個方法之前,所有非同步作業都已完成。

請參閱

參考

QueryableExtensions 類別

AverageAsync 多載

System.Data.Entity 命名空間