Method DeleteManyAsync
DeleteManyAsync<TDocument>(IMongoCollection<TDocument>, Expression<Func<TDocument, bool>>, CancellationToken)
Deletes multiple documents.
public static Task<DeleteResult> DeleteManyAsync<TDocument>(this IMongoCollection<TDocument> collection, Expression<Func<TDocument, bool>> filter, CancellationToken cancellationToken = default)
Parameters
collection
IMongoCollection<TDocument>The collection.
filter
Expression<Func<TDocument, bool>>The filter.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<DeleteResult>
The result of the delete operation.
Type Parameters
TDocument
The type of the document.
DeleteManyAsync<TDocument>(IMongoCollection<TDocument>, Expression<Func<TDocument, bool>>, DeleteOptions, CancellationToken)
Deletes multiple documents.
public static Task<DeleteResult> DeleteManyAsync<TDocument>(this IMongoCollection<TDocument> collection, Expression<Func<TDocument, bool>> filter, DeleteOptions options, CancellationToken cancellationToken = default)
Parameters
collection
IMongoCollection<TDocument>The collection.
filter
Expression<Func<TDocument, bool>>The filter.
options
DeleteOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<DeleteResult>
The result of the delete operation.
Type Parameters
TDocument
The type of the document.
DeleteManyAsync<TDocument>(IMongoCollection<TDocument>, IClientSessionHandle, Expression<Func<TDocument, bool>>, DeleteOptions, CancellationToken)
Deletes multiple documents.
public static Task<DeleteResult> DeleteManyAsync<TDocument>(this IMongoCollection<TDocument> collection, IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, DeleteOptions options = null, CancellationToken cancellationToken = default)
Parameters
collection
IMongoCollection<TDocument>The collection.
session
IClientSessionHandleThe session.
filter
Expression<Func<TDocument, bool>>The filter.
options
DeleteOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<DeleteResult>
The result of the delete operation.
Type Parameters
TDocument
The type of the document.