DbRawSqlQuery<TElement>.CountAsync Method (CancellationToken)
[This page is specific to the Entity Framework version 6. The latest version is available as the 'Entity Framework' NuGet package. For more information about Entity Framework, see msdn.com/data/ef.]
Asynchronously returns the number of elements in the query.
Namespace: System.Data.Entity.Infrastructure
Assembly: EntityFramework (in EntityFramework.dll)
Syntax
'Declaration
Public Function CountAsync ( _
cancellationToken As CancellationToken _
) As Task(Of Integer)
'Usage
Dim instance As DbRawSqlQuery
Dim cancellationToken As CancellationToken
Dim returnValue As Task(Of Integer)
returnValue = instance.CountAsync(cancellationToken)
public Task<int> CountAsync(
CancellationToken cancellationToken
)
public:
Task<int>^ CountAsync(
CancellationToken cancellationToken
)
member CountAsync :
cancellationToken:CancellationToken -> Task<int>
public function CountAsync(
cancellationToken : CancellationToken
) : Task<int>
Parameters
- cancellationToken
Type: System.Threading.CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Return Value
Type: System.Threading.Tasks.Task<Int32>
A task that represents the asynchronous operation. The task result contains the number of elements in the query result.
Exceptions
Exception | Condition |
---|---|
OverflowException | The number of elements in the query result is larger than MaxValue . |
Remarks
Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.