Method DeleteOneAsync
DeleteOneAsync<TDocument>(IMongoCollection<TDocument>, Expression<Func<TDocument, bool>>, CancellationToken)
Deletes a single document.
public static Task<DeleteResult> DeleteOneAsync<TDocument>(this IMongoCollection<TDocument> collection, Expression<Func<TDocument, bool>> filter, CancellationToken cancellationToken = default)
Parameters
collectionIMongoCollection<TDocument>The collection.
filterExpression<Func<TDocument, bool>>The filter.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<DeleteResult>
The result of the delete operation.
Type Parameters
TDocumentThe type of the document.
DeleteOneAsync<TDocument>(IMongoCollection<TDocument>, Expression<Func<TDocument, bool>>, DeleteOptions, CancellationToken)
Deletes a single document.
public static Task<DeleteResult> DeleteOneAsync<TDocument>(this IMongoCollection<TDocument> collection, Expression<Func<TDocument, bool>> filter, DeleteOptions options, CancellationToken cancellationToken = default)
Parameters
collectionIMongoCollection<TDocument>The collection.
filterExpression<Func<TDocument, bool>>The filter.
optionsDeleteOptionsThe options.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<DeleteResult>
The result of the delete operation.
Type Parameters
TDocumentThe type of the document.
DeleteOneAsync<TDocument>(IMongoCollection<TDocument>, IClientSessionHandle, Expression<Func<TDocument, bool>>, DeleteOptions, CancellationToken)
Deletes a single document.
public static Task<DeleteResult> DeleteOneAsync<TDocument>(this IMongoCollection<TDocument> collection, IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, DeleteOptions options = null, CancellationToken cancellationToken = default)
Parameters
collectionIMongoCollection<TDocument>The collection.
sessionIClientSessionHandleThe session.
filterExpression<Func<TDocument, bool>>The filter.
optionsDeleteOptionsThe options.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<DeleteResult>
The result of the delete operation.
Type Parameters
TDocumentThe type of the document.