Share via


DbRawSqlQuery<TElement>.CountAsync 方法

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

非同步傳回查詢中的項目數。

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

語法

'宣告
Public Function CountAsync As Task(Of Integer)
'用途
Dim instance As DbRawSqlQuery 
Dim returnValue As Task(Of Integer)

returnValue = instance.CountAsync()
public Task<int> CountAsync()
public:
Task<int>^ CountAsync()
member CountAsync : unit -> Task<int> 
public function CountAsync() : Task<int>

傳回值

類型:System.Threading.Tasks.Task<Int32>
表示非同步作業的工作。工作結果包含查詢結果中的項目數。

例外狀況

例外狀況 條件
OverflowException

查詢結果中的項目數大於 MaxValue

備註

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

請參閱

參考

DbRawSqlQuery<TElement> 類別

CountAsync 多載

System.Data.Entity.Infrastructure 命名空間