Table of Contents

Method DeleteMany

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

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

Deletes multiple documents.

public static DeleteResult DeleteMany<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.

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

Deletes multiple documents.

public static DeleteResult DeleteMany<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.

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

Deletes multiple documents.

public static DeleteResult DeleteMany<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.