Method LongCountAsync
LongCountAsync<TSource>(IQueryable<TSource>, CancellationToken)
Returns the number of elements in a sequence.
public static Task<long> LongCountAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = default)
Parameters
sourceIQueryable<TSource>The IQueryable<T> that contains the elements to be counted.
cancellationTokenCancellationTokenThe cancellation token.
Returns
Type Parameters
TSourceThe type of the elements of
source.
LongCountAsync<TSource>(IQueryable<TSource>, Expression<Func<TSource, bool>>, CancellationToken)
Returns the number of elements in the specified sequence that satisfies a condition.
public static Task<long> LongCountAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = default)
Parameters
sourceIQueryable<TSource>An IQueryable<T> that contains the elements to be counted.
predicateExpression<Func<TSource, bool>>A function to test each element for a condition.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<long>
The number of elements in the sequence that satisfies the condition in the predicate function.
Type Parameters
TSourceThe type of the elements of
source.