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