Method CountAsync
CountAsync<TDocument>(IMongoCollection<TDocument>, Expression<Func<TDocument, bool>>, CountOptions, CancellationToken)
Counts the number of documents in the collection.
[Obsolete("Use CountDocumentsAsync or EstimatedDocumentCountAsync instead.")]
public static Task<long> CountAsync<TDocument>(this IMongoCollection<TDocument> collection, Expression<Func<TDocument, bool>> filter, CountOptions options = null, CancellationToken cancellationToken = default)
Parameters
collection
IMongoCollection<TDocument>The collection.
filter
Expression<Func<TDocument, bool>>The filter.
options
CountOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
Type Parameters
TDocument
The type of the document.
CountAsync<TDocument>(IMongoCollection<TDocument>, IClientSessionHandle, Expression<Func<TDocument, bool>>, CountOptions, CancellationToken)
Counts the number of documents in the collection.
[Obsolete("Use CountDocumentsAsync or EstimatedDocumentCountAsync instead.")]
public static Task<long> CountAsync<TDocument>(this IMongoCollection<TDocument> collection, IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, CountOptions options = null, CancellationToken cancellationToken = default)
Parameters
collection
IMongoCollection<TDocument>The collection.
session
IClientSessionHandleThe session.
filter
Expression<Func<TDocument, bool>>The filter.
options
CountOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
Type Parameters
TDocument
The type of the document.