EntityFrameworkQueryableExtensions.LongCountAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
|
LongCountAsync |
Asynchronously returns a Int64 that represents the number of elements in a sequence that satisfy a condition. |
|
LongCountAsync |
Asynchronously returns a Int64 that represents the total number of elements in a sequence. |
LongCountAsync(IQueryable, Expression>, CancellationToken)
Asynchronously returns a Int64 that represents the number of elements in a sequence that satisfy a condition.
public static System.Threading.Tasks.Task LongCountAsync(this System.Linq.IQueryable source, System.Linq.Expressions.Expression> predicate, System.Threading.CancellationToken cancellationToken = default);
static member LongCountAsync : System.Linq.IQueryable<'Source> * System.Linq.Expressions.Expression> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function LongCountAsync(Of TSource) (source As IQueryable(Of TSource), predicate As Expression(Of Func(Of TSource, Boolean)), Optional cancellationToken As CancellationToken = Nothing) As Task(Of Long)
Type Parameters
- TSource
The type of the elements of source.
Parameters
- source
-
IQueryable
An IQueryable
- predicate
-
Expression<Func
Boolean>>
A function to test each element for a condition.
- cancellationToken
- CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Returns
A task that represents the asynchronous operation. The task result contains the number of elements in the sequence that satisfy the condition in the predicate function.
Exceptions
source or predicate is null.
If the CancellationToken is canceled.
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. See Avoiding DbContext threading issues for more information and examples.
See Querying data with EF Core for more information and examples.
Applies to
LongCountAsync(IQueryable, CancellationToken)
Asynchronously returns a Int64 that represents the total number of elements in a sequence.
public static System.Threading.Tasks.Task LongCountAsync(this System.Linq.IQueryable source, System.Threading.CancellationToken cancellationToken = default);
static member LongCountAsync : System.Linq.IQueryable<'Source> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function LongCountAsync(Of TSource) (source As IQueryable(Of TSource), Optional cancellationToken As CancellationToken = Nothing) As Task(Of Long)
Type Parameters
- TSource
The type of the elements of source.
Parameters
- source
-
IQueryable
An IQueryable
- cancellationToken
- CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Returns
A task that represents the asynchronous operation. The task result contains the number of elements in the input sequence.
Exceptions
source is null.
If the CancellationToken is canceled.
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. See Avoiding DbContext threading issues for more information and examples.
See Querying data with EF Core for more information and examples.