Method CountAsync
| MongoDB CSharp Driver API Reference (original) (raw)
Namespace
Assembly
MongoDB.Driver.dll
CountAsync(IQueryable, CancellationToken)
Returns the number of elements in a sequence.
public static Task<int> CountAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = default)
Parameters
source
IQueryable
The IQueryable that contains the elements to be counted.
cancellationToken
CancellationToken
The cancellation token.
Returns
The number of elements in the input sequence.
Type Parameters
TSource
The type of the elements of source
.
CountAsync(IQueryable, Expression<Func<TSource, bool>>, CancellationToken)
Returns the number of elements in the specified sequence that satisfies a condition.
public static Task<int> CountAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = default)
Parameters
source
IQueryable
An IQueryable that contains the elements to be counted.
predicate
Expression<Func<TSource, bool>>
A function to test each element for a condition.
cancellationToken
CancellationToken
The cancellation token.
Returns
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
.