Table of Contents

Method DeleteOne

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

DeleteOne<TDocument>(IMongoCollection<TDocument>, Expression<Func<TDocument, bool>>, CancellationToken)

Deletes a single document.

public static DeleteResult DeleteOne<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 CancellationToken

The cancellation token.

Returns

DeleteResult

The result of the delete operation.

Type Parameters

TDocument

The type of the document.

DeleteOne<TDocument>(IMongoCollection<TDocument>, Expression<Func<TDocument, bool>>, DeleteOptions, CancellationToken)

Deletes a single document.

public static DeleteResult DeleteOne<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 DeleteOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

DeleteResult

The result of the delete operation.

Type Parameters

TDocument

The type of the document.

DeleteOne<TDocument>(IMongoCollection<TDocument>, IClientSessionHandle, Expression<Func<TDocument, bool>>, DeleteOptions, CancellationToken)

Deletes a single document.

public static DeleteResult DeleteOne<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 IClientSessionHandle

The session.

filter Expression<Func<TDocument, bool>>

The filter.

options DeleteOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

DeleteResult

The result of the delete operation.

Type Parameters

TDocument

The type of the document.