Method FindOneAndReplaceAsync
| MongoDB CSharp Driver API Reference (original) (raw)
Namespace
Assembly
MongoDB.Driver.dll
FindOneAndReplaceAsync(IMongoCollection, FilterDefinition, TDocument, FindOneAndReplaceOptions<TDocument, TDocument>, CancellationToken)
Finds a single document and replaces it atomically.
public static Task<TDocument> FindOneAndReplaceAsync<TDocument>(this IMongoCollection<TDocument> collection, FilterDefinition<TDocument> filter, TDocument replacement, FindOneAndReplaceOptions<TDocument, TDocument> options = null, CancellationToken cancellationToken = default)Parameters
collection IMongoCollection
The collection.
filter FilterDefinition
The filter.
replacement TDocument
The replacement.
options FindOneAndReplaceOptions<TDocument, TDocument>
The options.
cancellationToken CancellationToken
The cancellation token.
Returns
The returned document.
Type Parameters
TDocument
The type of the document.
FindOneAndReplaceAsync(IMongoCollection, Expression<Func<TDocument, bool>>, TDocument, FindOneAndReplaceOptions, CancellationToken)
Finds a single document and replaces it atomically.
public static Task<TDocument> FindOneAndReplaceAsync<TDocument>(this IMongoCollection<TDocument> collection, Expression<Func<TDocument, bool>> filter, TDocument replacement, FindOneAndReplaceOptions<TDocument> options = null, CancellationToken cancellationToken = default)Parameters
collection IMongoCollection
The collection.
filter Expression<Func<TDocument, bool>>
The filter.
replacement TDocument
The replacement.
options FindOneAndReplaceOptions
The options.
cancellationToken CancellationToken
The cancellation token.
Returns
The returned document.
Type Parameters
TDocument
The type of the document.
FindOneAndReplaceAsync<TDocument, TProjection>(IMongoCollection, Expression<Func<TDocument, bool>>, TDocument, FindOneAndReplaceOptions<TDocument, TProjection>, CancellationToken)
Finds a single document and replaces it atomically.
public static Task<TProjection> FindOneAndReplaceAsync<TDocument, TProjection>(this IMongoCollection<TDocument> collection, Expression<Func<TDocument, bool>> filter, TDocument replacement, FindOneAndReplaceOptions<TDocument, TProjection> options = null, CancellationToken cancellationToken = default)Parameters
collection IMongoCollection
The collection.
filter Expression<Func<TDocument, bool>>
The filter.
replacement TDocument
The replacement.
options FindOneAndReplaceOptions<TDocument, TProjection>
The options.
cancellationToken CancellationToken
The cancellation token.
Returns
The returned document.
Type Parameters
TDocument
The type of the document.
TProjection
The type of the projection (same as TDocument if there is no projection).
FindOneAndReplaceAsync(IMongoCollection, IClientSessionHandle, FilterDefinition, TDocument, FindOneAndReplaceOptions<TDocument, TDocument>, CancellationToken)
Finds a single document and replaces it atomically.
public static Task<TDocument> FindOneAndReplaceAsync<TDocument>(this IMongoCollection<TDocument> collection, IClientSessionHandle session, FilterDefinition<TDocument> filter, TDocument replacement, FindOneAndReplaceOptions<TDocument, TDocument> options = null, CancellationToken cancellationToken = default)Parameters
collection IMongoCollection
The collection.
session IClientSessionHandle
The session.
filter FilterDefinition
The filter.
replacement TDocument
The replacement.
options FindOneAndReplaceOptions<TDocument, TDocument>
The options.
cancellationToken CancellationToken
The cancellation token.
Returns
The returned document.
Type Parameters
TDocument
The type of the document.
FindOneAndReplaceAsync(IMongoCollection, Expression<Func<TDocument, bool>>, IClientSessionHandle, TDocument, FindOneAndReplaceOptions<TDocument, TDocument>, CancellationToken)
Finds a single document and replaces it atomically.
public static Task<TDocument> FindOneAndReplaceAsync<TDocument>(this IMongoCollection<TDocument> collection, Expression<Func<TDocument, bool>> filter, IClientSessionHandle session, TDocument replacement, FindOneAndReplaceOptions<TDocument, TDocument> options = null, CancellationToken cancellationToken = default)Parameters
collection IMongoCollection
The collection.
filter Expression<Func<TDocument, bool>>
The filter.
session IClientSessionHandle
The session.
replacement TDocument
The replacement.
options FindOneAndReplaceOptions<TDocument, TDocument>
The options.
cancellationToken CancellationToken
The cancellation token.
Returns
The returned document.
Type Parameters
TDocument
The type of the document.
FindOneAndReplaceAsync<TDocument, TProjection>(IMongoCollection, IClientSessionHandle, Expression<Func<TDocument, bool>>, TDocument, FindOneAndReplaceOptions<TDocument, TProjection>, CancellationToken)
Finds a single document and replaces it atomically.
public static Task<TProjection> FindOneAndReplaceAsync<TDocument, TProjection>(this IMongoCollection<TDocument> collection, IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, TDocument replacement, FindOneAndReplaceOptions<TDocument, TProjection> options = null, CancellationToken cancellationToken = default)Parameters
collection IMongoCollection
The collection.
session IClientSessionHandle
The session.
filter Expression<Func<TDocument, bool>>
The filter.
replacement TDocument
The replacement.
options FindOneAndReplaceOptions<TDocument, TProjection>
The options.
cancellationToken CancellationToken
The cancellation token.
Returns
The returned document.
Type Parameters
TDocument
The type of the document.
TProjection
The type of the projection (same as TDocument if there is no projection).