Method ReplaceOne
ReplaceOne(FilterDefinition<TDocument>, TDocument, ReplaceOptions, CancellationToken)
Replaces a single document.
public virtual ReplaceOneResult ReplaceOne(FilterDefinition<TDocument> filter, TDocument replacement, ReplaceOptions options = null, CancellationToken cancellationToken = default)
Parameters
filter
FilterDefinition<TDocument>The filter.
replacement
TDocumentThe replacement.
options
ReplaceOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- ReplaceOneResult
The result of the replacement.
ReplaceOne(FilterDefinition<TDocument>, TDocument, UpdateOptions, CancellationToken)
Replaces a single document.
[Obsolete("Use the overload that takes a ReplaceOptions instead of an UpdateOptions.")]
public virtual ReplaceOneResult ReplaceOne(FilterDefinition<TDocument> filter, TDocument replacement, UpdateOptions options, CancellationToken cancellationToken = default)
Parameters
filter
FilterDefinition<TDocument>The filter.
replacement
TDocumentThe replacement.
options
UpdateOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- ReplaceOneResult
The result of the replacement.
ReplaceOne(IClientSessionHandle, FilterDefinition<TDocument>, TDocument, ReplaceOptions, CancellationToken)
Replaces a single document.
public virtual ReplaceOneResult ReplaceOne(IClientSessionHandle session, FilterDefinition<TDocument> filter, TDocument replacement, ReplaceOptions options = null, CancellationToken cancellationToken = default)
Parameters
session
IClientSessionHandleThe session.
filter
FilterDefinition<TDocument>The filter.
replacement
TDocumentThe replacement.
options
ReplaceOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- ReplaceOneResult
The result of the replacement.
ReplaceOne(IClientSessionHandle, FilterDefinition<TDocument>, TDocument, UpdateOptions, CancellationToken)
Replaces a single document.
[Obsolete("Use the overload that takes a ReplaceOptions instead of an UpdateOptions.")]
public virtual ReplaceOneResult ReplaceOne(IClientSessionHandle session, FilterDefinition<TDocument> filter, TDocument replacement, UpdateOptions options, CancellationToken cancellationToken = default)
Parameters
session
IClientSessionHandleThe session.
filter
FilterDefinition<TDocument>The filter.
replacement
TDocumentThe replacement.
options
UpdateOptionsThe options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- ReplaceOneResult
The result of the replacement.