cancellation tokens on repository update methods

This commit is contained in:
Sean Garrett
2023-07-06 11:49:45 +01:00
parent be58460bf1
commit c70727212e
5 changed files with 2332 additions and 741 deletions
@@ -12,6 +12,38 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// </summary> /// </summary>
public interface IBaseMongoRepository_Update_ClientSession public interface IBaseMongoRepository_Update_ClientSession
{ {
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary> /// <summary>
/// Updates a document. /// Updates a document.
/// </summary> /// </summary>
@@ -23,9 +55,8 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// <param name="field">The field to update.</param> /// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param> /// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param> /// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns> /// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -42,7 +73,86 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// <param name="partitionKey">The optional partition key.</param> /// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns> /// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param>
/// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="documentToModify">The document to modify.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -58,7 +168,19 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// <param name="value">The value of the field.</param> /// <param name="value">The value of the field.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns> /// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken = default(CancellationToken)) bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
/// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -71,7 +193,20 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param> /// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns> /// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken)) bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="documentToModify">The document to modify.</param>
/// <param name="update">The update definition.</param>
/// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -85,7 +220,54 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// <param name="update">The update definition.</param> /// <param name="update">The update definition.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns> /// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken = default(CancellationToken)) bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <returns>A boolean value indicating success.</returns>
Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns>
Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param>
/// <returns>A boolean value indicating success.</returns>
Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -102,7 +284,54 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// <param name="partitionKey">The optional partition key.</param> /// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns> /// <returns>A boolean value indicating success.</returns>
Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <returns></returns>
Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns>
Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param>
/// <returns></returns>
Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -119,7 +348,7 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// <param name="partitionKey">The optional partition key.</param> /// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns> /// <returns></returns>
Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -129,13 +358,40 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam> /// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param> /// <param name="session">The client session.</param>
/// <param name="documentToModify">The document to modify.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <returns>A boolean value indicating success.</returns>
Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="documentToModify">The document to modify.</param> /// <param name="documentToModify">The document to modify.</param>
/// <param name="field">The field to update.</param> /// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param> /// <param name="value">The value of the field.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns> /// <returns>A boolean value indicating success.</returns>
Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken = default(CancellationToken)) Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
/// <returns>A boolean value indicating success.</returns>
Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -148,7 +404,20 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param> /// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns> /// <returns>A boolean value indicating success.</returns>
Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken)) Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="session">The client session.</param>
/// <param name="documentToModify">The document to modify.</param>
/// <param name="update">The update definition.</param>
/// <returns>A boolean value indicating success.</returns>
Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -162,7 +431,7 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// <param name="update">The update definition.</param> /// <param name="update">The update definition.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns> /// <returns>A boolean value indicating success.</returns>
Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken = default(CancellationToken)) Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
} }
@@ -1,197 +1,350 @@
using MongoDB.Driver; using System;
using MongoDbGenericRepository.DataAccess.Update;
using MongoDbGenericRepository.Models;
using System;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MongoDB.Driver;
using MongoDbGenericRepository.DataAccess.Update;
using MongoDbGenericRepository.Models;
namespace MongoDbGenericRepository namespace MongoDbGenericRepository
{ {
public abstract partial class BaseMongoRepository : IBaseMongoRepository_Update_ClientSession public abstract partial class BaseMongoRepository : IBaseMongoRepository_Update_ClientSession
{ {
/// <summary> /// <inheritdoc />
/// Updates a document. public virtual async Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument)
/// </summary> where TDocument : IDocument<TKey>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> where TKey : IEquatable<TKey>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> {
/// <param name="session">The client session.</param> return await UpdateOneAsync<TDocument, TKey>(session, modifiedDocument, CancellationToken.None);
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param> }
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns> /// <inheritdoc />
public virtual async Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken)) public virtual async Task<bool> UpdateOneAsync<TDocument, TKey>(
IClientSessionHandle session,
TDocument modifiedDocument,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey>(session, modifiedDocument, cancellationToken); return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey>(session, modifiedDocument, cancellationToken);
} }
/// <summary> /// <inheritdoc />
/// Updates a document. public virtual bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument)
/// </summary> where TDocument : IDocument<TKey>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> where TKey : IEquatable<TKey>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> {
/// <param name="session">The client session.</param> return UpdateOne<TDocument, TKey>(session, modifiedDocument, CancellationToken.None);
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param> }
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns> /// <inheritdoc />
public virtual bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken)) public virtual bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return MongoDbUpdater.UpdateOne<TDocument, TKey>(session, modifiedDocument, cancellationToken); return MongoDbUpdater.UpdateOne<TDocument, TKey>(session, modifiedDocument, cancellationToken);
} }
/// <summary> /// <inheritdoc />
/// Updates a document. public virtual async Task<bool> UpdateOneAsync<TDocument, TKey>(
/// </summary> IClientSessionHandle session,
/// <typeparam name="TDocument">The type representing a Document.</typeparam> TDocument documentToModify,
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> UpdateDefinition<TDocument> update)
/// <param name="session">The client session.</param> where TDocument : IDocument<TKey>
/// <param name="documentToModify">The document to modify.</param> where TKey : IEquatable<TKey>
/// <param name="update">The update definition.</param> {
/// <param name="cancellationToken">The optional cancellation token.</param> return await UpdateOneAsync<TDocument, TKey>(session, documentToModify, update, CancellationToken.None);
/// <returns>A boolean value indicating success.</returns> }
public virtual async Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken = default(CancellationToken))
/// <inheritdoc />
public virtual async Task<bool> UpdateOneAsync<TDocument, TKey>(
IClientSessionHandle session,
TDocument documentToModify,
UpdateDefinition<TDocument> update,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey>(session, documentToModify, update, cancellationToken); return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey>(session, documentToModify, update, cancellationToken);
} }
/// <summary> /// <inheritdoc />
/// Updates a document. public virtual bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update)
/// </summary> where TDocument : IDocument<TKey>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> where TKey : IEquatable<TKey>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> {
/// <param name="session">The client session.</param> return UpdateOne<TDocument, TKey>(session, documentToModify, update, CancellationToken.None);
/// <param name="documentToModify">The document to modify.</param> }
/// <param name="update">The update definition.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <inheritdoc />
/// <returns>A boolean value indicating success.</returns> public virtual bool UpdateOne<TDocument, TKey>(
public virtual bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken = default(CancellationToken)) IClientSessionHandle session,
TDocument documentToModify,
UpdateDefinition<TDocument> update,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return MongoDbUpdater.UpdateOne<TDocument, TKey>(session, documentToModify, update, cancellationToken); return MongoDbUpdater.UpdateOne<TDocument, TKey>(session, documentToModify, update, cancellationToken);
} }
/// <summary> /// <inheritdoc />
/// Updates a document. public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(
/// </summary> IClientSessionHandle session,
/// <typeparam name="TDocument">The type representing a Document.</typeparam> TDocument documentToModify,
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> Expression<Func<TDocument, TField>> field,
/// <typeparam name="TField">The type of the field to update.</typeparam> TField value)
/// <param name="session">The client session.</param> where TDocument : IDocument<TKey>
/// <param name="documentToModify">The document to modify.</param> where TKey : IEquatable<TKey>
/// <param name="field">The field to update.</param> {
/// <param name="value">The value of the field.</param> return await UpdateOneAsync<TDocument, TKey, TField>(session, documentToModify, field, value, CancellationToken.None);
/// <param name="cancellationToken">The optional cancellation token.</param> }
/// <returns>A boolean value indicating success.</returns>
public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken = default(CancellationToken)) /// <inheritdoc />
public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(
IClientSessionHandle session,
TDocument documentToModify,
Expression<Func<TDocument, TField>> field,
TField value,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey, TField>(session, documentToModify, field, value, cancellationToken); return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey, TField>(session, documentToModify, field, value, cancellationToken);
} }
/// <summary> /// <inheritdoc />
/// Updates a document. public virtual bool UpdateOne<TDocument, TKey, TField>(
/// </summary> IClientSessionHandle session,
/// <typeparam name="TDocument">The type representing a Document.</typeparam> TDocument documentToModify,
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> Expression<Func<TDocument, TField>> field,
/// <typeparam name="TField">The type of the field to update.</typeparam> TField value)
/// <param name="session">The client session.</param> where TDocument : IDocument<TKey>
/// <param name="documentToModify">The document to modify.</param> where TKey : IEquatable<TKey>
/// <param name="field">The field to update.</param> {
/// <param name="value">The value of the field.</param> return UpdateOne<TDocument, TKey, TField>(session, documentToModify, field, value, CancellationToken.None);
/// <param name="cancellationToken">The optional cancellation token.</param> }
/// <returns>A boolean value indicating success.</returns>
public virtual bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken = default(CancellationToken)) /// <inheritdoc />
public virtual bool UpdateOne<TDocument, TKey, TField>(
IClientSessionHandle session,
TDocument documentToModify,
Expression<Func<TDocument, TField>> field,
TField value,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return MongoDbUpdater.UpdateOne<TDocument, TKey, TField>(session, documentToModify, field, value, cancellationToken); return MongoDbUpdater.UpdateOne<TDocument, TKey, TField>(session, documentToModify, field, value, cancellationToken);
} }
/// <summary> /// <inheritdoc />
/// Updates a document. public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(
/// </summary> IClientSessionHandle session,
/// <typeparam name="TDocument">The type representing a Document.</typeparam> FilterDefinition<TDocument> filter,
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> Expression<Func<TDocument, TField>> field,
/// <typeparam name="TField">The type of the field to update.</typeparam> TField value)
/// <param name="session">The client session.</param> where TDocument : IDocument<TKey>
/// <param name="filter">The filter for the update.</param> where TKey : IEquatable<TKey>
/// <param name="field">The field to update.</param> {
/// <param name="value">The value of the field.</param> return await UpdateOneAsync<TDocument, TKey, TField>(session, filter, field, value, null, CancellationToken.None);
/// <param name="partitionKey">The optional partition key.</param> }
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns> /// <inheritdoc />
public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(
IClientSessionHandle session,
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await UpdateOneAsync<TDocument, TKey, TField>(session, filter, field, value, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(
IClientSessionHandle session,
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await UpdateOneAsync<TDocument, TKey, TField>(session, filter, field, value, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(
IClientSessionHandle session,
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey, TField>(session, filter, field, value, partitionKey, cancellationToken); return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey, TField>(session, filter, field, value, partitionKey, cancellationToken);
} }
/// <summary> /// <inheritdoc />
/// Updates a document. public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(
/// </summary> IClientSessionHandle session,
/// <typeparam name="TDocument">The type representing a Document.</typeparam> Expression<Func<TDocument, bool>> filter,
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> Expression<Func<TDocument, TField>> field,
/// <typeparam name="TField">The type of the field to update.</typeparam> TField value)
/// <param name="session">The client session.</param> where TDocument : IDocument<TKey>
/// <param name="filter">The filter for the update.</param> where TKey : IEquatable<TKey>
/// <param name="field">The field to update.</param> {
/// <param name="value">The value of the field.</param> return await UpdateOneAsync<TDocument, TKey, TField>(session, filter, field, value, null, CancellationToken.None);
/// <param name="partitionKey">The optional partition key.</param> }
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns> /// <inheritdoc />
public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(
IClientSessionHandle session,
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await UpdateOneAsync<TDocument, TKey, TField>(session, filter, field, value, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(
IClientSessionHandle session,
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await UpdateOneAsync<TDocument, TKey, TField>(session, filter, field, value, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(
IClientSessionHandle session,
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey, TField>(session, filter, field, value, partitionKey, cancellationToken); return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey, TField>(session, filter, field, value, partitionKey, cancellationToken);
} }
/// <summary> /// <inheritdoc />
/// Updates a document. public virtual bool UpdateOne<TDocument, TKey, TField>(
/// </summary> IClientSessionHandle session,
/// <typeparam name="TDocument">The type representing a Document.</typeparam> FilterDefinition<TDocument> filter,
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> Expression<Func<TDocument, TField>> field,
/// <typeparam name="TField">The type of the field to update.</typeparam> TField value)
/// <param name="session">The client session.</param> where TDocument : IDocument<TKey>
/// <param name="filter">The filter for the update.</param> where TKey : IEquatable<TKey>
/// <param name="field">The field to update.</param> {
/// <param name="value">The value of the field.</param> return UpdateOne<TDocument, TKey, TField>(session, filter, field, value, null, CancellationToken.None);
/// <param name="partitionKey">The optional partition key.</param> }
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns>
public virtual bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) /// <inheritdoc />
public virtual bool UpdateOne<TDocument, TKey, TField>(
IClientSessionHandle session,
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return UpdateOne<TDocument, TKey, TField>(session, filter, field, value, null, cancellationToken);
}
/// <inheritdoc />
public virtual bool UpdateOne<TDocument, TKey, TField>(
IClientSessionHandle session,
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return UpdateOne<TDocument, TKey, TField>(session, filter, field, value, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual bool UpdateOne<TDocument, TKey, TField>(
IClientSessionHandle session,
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return MongoDbUpdater.UpdateOne<TDocument, TKey, TField>(session, filter, field, value, partitionKey, cancellationToken); return MongoDbUpdater.UpdateOne<TDocument, TKey, TField>(session, filter, field, value, partitionKey, cancellationToken);
} }
/// <summary> /// <inheritdoc />
/// Updates a document. public virtual bool UpdateOne<TDocument, TKey, TField>(
/// </summary> IClientSessionHandle session,
/// <typeparam name="TDocument">The type representing a Document.</typeparam> Expression<Func<TDocument, bool>> filter,
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> Expression<Func<TDocument, TField>> field,
/// <typeparam name="TField">The type of the field to update.</typeparam> TField value)
/// <param name="session">The client session.</param> where TDocument : IDocument<TKey>
/// <param name="filter">The filter for the update.</param> where TKey : IEquatable<TKey>
/// <param name="field">The field to update.</param> {
/// <param name="value">The value of the field.</param> return UpdateOne<TDocument, TKey, TField>(session, Builders<TDocument>.Filter.Where(filter), field, value, null, CancellationToken.None);
/// <param name="partitionKey">The optional partition key.</param> }
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns> /// <inheritdoc />
public virtual bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) public virtual bool UpdateOne<TDocument, TKey, TField>(
IClientSessionHandle session,
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return UpdateOne<TDocument, TKey, TField>(session, Builders<TDocument>.Filter.Where(filter), field, value, null, cancellationToken);
}
/// <inheritdoc />
public virtual bool UpdateOne<TDocument, TKey, TField>(
IClientSessionHandle session,
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return UpdateOne<TDocument, TKey, TField>(session, Builders<TDocument>.Filter.Where(filter), field, value, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual bool UpdateOne<TDocument, TKey, TField>(
IClientSessionHandle session,
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return UpdateOne<TDocument, TKey, TField>(session, Builders<TDocument>.Filter.Where(filter), field, value, partitionKey, cancellationToken); return UpdateOne<TDocument, TKey, TField>(session, Builders<TDocument>.Filter.Where(filter), field, value, partitionKey, cancellationToken);
} }
} }
} }
File diff suppressed because it is too large Load Diff
@@ -3,6 +3,7 @@ using MongoDbGenericRepository.DataAccess.Update;
using MongoDbGenericRepository.Models; using MongoDbGenericRepository.Models;
using System; using System;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace MongoDbGenericRepository namespace MongoDbGenericRepository
@@ -34,247 +35,424 @@ namespace MongoDbGenericRepository
set { _mongoDbUpdater = value; } set { _mongoDbUpdater = value; }
} }
/// <summary> /// <inheritdoc />
/// Asynchronously Updates a document. public virtual async Task<bool> UpdateOneAsync<TDocument>(TDocument modifiedDocument)
/// </summary> where TDocument : IDocument<TKey>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
public virtual async Task<bool> UpdateOneAsync<TDocument>(TDocument modifiedDocument) where TDocument : IDocument<TKey>
{ {
return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey>(modifiedDocument); return await UpdateOneAsync(modifiedDocument, CancellationToken.None);
} }
/// <summary> /// <inheritdoc />
/// Updates a document. public virtual async Task<bool> UpdateOneAsync<TDocument>(TDocument modifiedDocument, CancellationToken cancellationToken)
/// </summary> where TDocument : IDocument<TKey>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
public virtual bool UpdateOne<TDocument>(TDocument modifiedDocument) where TDocument : IDocument<TKey>
{ {
return MongoDbUpdater.UpdateOne<TDocument, TKey>(modifiedDocument); return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey>(modifiedDocument, cancellationToken);
} }
/// <summary> /// <inheritdoc />
/// Takes a document you want to modify and applies the update you have defined in MongoDb. public virtual bool UpdateOne<TDocument>(TDocument modifiedDocument)
/// </summary> where TDocument : IDocument<TKey>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> {
/// <param name="documentToModify">The document you want to modify.</param> return UpdateOne(modifiedDocument, CancellationToken.None);
/// <param name="update">The update definition for the document.</param> }
/// <inheritdoc />
public virtual bool UpdateOne<TDocument>(TDocument modifiedDocument, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return MongoDbUpdater.UpdateOne<TDocument, TKey>(modifiedDocument, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<bool> UpdateOneAsync<TDocument>(TDocument documentToModify, UpdateDefinition<TDocument> update) public virtual async Task<bool> UpdateOneAsync<TDocument>(TDocument documentToModify, UpdateDefinition<TDocument> update)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
{ {
return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey>(documentToModify, update); return await UpdateOneAsync(documentToModify, update, CancellationToken.None);
} }
/// <summary> /// <inheritdoc />
/// Takes a document you want to modify and applies the update you have defined in MongoDb. public virtual async Task<bool> UpdateOneAsync<TDocument>(TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken)
/// </summary> where TDocument : IDocument<TKey>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> {
/// <param name="documentToModify">The document you want to modify.</param> return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey>(documentToModify, update, cancellationToken);
/// <param name="update">The update definition for the document.</param> }
/// <inheritdoc />
public virtual bool UpdateOne<TDocument>(TDocument documentToModify, UpdateDefinition<TDocument> update) public virtual bool UpdateOne<TDocument>(TDocument documentToModify, UpdateDefinition<TDocument> update)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
{ {
return MongoDbUpdater.UpdateOne<TDocument, TKey>(documentToModify, update); return UpdateOne(documentToModify, update, CancellationToken.None);
} }
/// <summary> /// <inheritdoc />
/// Updates the property field with the given value update a property field in entities. public virtual bool UpdateOne<TDocument>(TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken)
/// </summary> where TDocument : IDocument<TKey>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> {
/// <typeparam name="TField">The type of the field.</typeparam> return MongoDbUpdater.UpdateOne<TDocument, TKey>(documentToModify, update, cancellationToken);
/// <param name="documentToModify">The document you want to modify.</param> }
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param> /// <inheritdoc />
public virtual bool UpdateOne<TDocument, TField>(TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value) public virtual bool UpdateOne<TDocument, TField>(TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
{ {
return MongoDbUpdater.UpdateOne<TDocument, TKey, TField>(documentToModify, field, value); return UpdateOne(documentToModify, field, value, CancellationToken.None);
} }
/// <summary> /// <inheritdoc />
/// Updates the property field with the given value update a property field in entities. public virtual bool UpdateOne<TDocument, TField>(TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken)
/// </summary> where TDocument : IDocument<TKey>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> {
/// <typeparam name="TField">The type of the field.</typeparam> return MongoDbUpdater.UpdateOne<TDocument, TKey, TField>(documentToModify, field, value, cancellationToken);
/// <param name="documentToModify">The document you want to modify.</param> }
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param> /// <inheritdoc />
public virtual async Task<bool> UpdateOneAsync<TDocument, TField>(TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value) public virtual async Task<bool> UpdateOneAsync<TDocument, TField>(TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
{ {
return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey, TField>(documentToModify, field, value); return await UpdateOneAsync(documentToModify, field, value, CancellationToken.None);
} }
/// <summary> /// <inheritdoc />
/// Updates the property field with the given value update a property field in entities. public virtual async Task<bool> UpdateOneAsync<TDocument, TField>(TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken)
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual bool UpdateOne<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
{ {
return MongoDbUpdater.UpdateOne<TDocument, TKey, TField>(filter, field, value, partitionKey); return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey, TField>(documentToModify, field, value, cancellationToken);
} }
/// <summary> /// <inheritdoc />
/// For the entity selected by the filter, updates the property field with the given value. public virtual bool UpdateOne<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value)
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
public virtual bool UpdateOne<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
{ {
return MongoDbUpdater.UpdateOne<TDocument, TKey, TField>(filter, field, value, partitionKey); return UpdateOne(filter, field, value, null, CancellationToken.None);
} }
/// <summary> /// <inheritdoc />
/// Updates the property field with the given value update a property field in entities. public virtual bool UpdateOne<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken)
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual async Task<bool> UpdateOneAsync<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
{ {
return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey, TField>(filter, field, value, partitionKey); return UpdateOne(filter, field, value, null, cancellationToken);
} }
/// <summary> /// <inheritdoc />
/// For the entity selected by the filter, updates the property field with the given value. public virtual bool UpdateOne<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey)
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
public virtual async Task<bool> UpdateOneAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
{ {
return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey, TField>(filter, field, value, partitionKey); return UpdateOne(filter, field, value, partitionKey, CancellationToken.None);
} }
/// <summary> /// <inheritdoc />
/// For the entities selected by the filter, updates the property field with the given value. public virtual bool UpdateOne<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey, CancellationToken cancellationToken)
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
public virtual async Task<long> UpdateManyAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
{ {
return await MongoDbUpdater.UpdateManyAsync<TDocument, TKey, TField>(filter, field, value, partitionKey); return MongoDbUpdater.UpdateOne<TDocument, TKey, TField>(filter, field, value, partitionKey, cancellationToken);
} }
/// <summary> /// <inheritdoc />
/// For the entities selected by the filter, updates the property field with the given value. public virtual bool UpdateOne<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value)
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual async Task<long> UpdateManyAsync<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
{ {
return await MongoDbUpdater.UpdateManyAsync<TDocument, TKey, TField>(filter, field, value, partitionKey); return UpdateOne(filter, field, value, null, CancellationToken.None);
} }
/// <summary> /// <inheritdoc />
/// For the entities selected by the filter, applies the update you have defined in MongoDb. public virtual bool UpdateOne<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken)
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual async Task<long> UpdateManyAsync<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
{ {
return await MongoDbUpdater.UpdateManyAsync<TDocument, TKey>(filter, updateDefinition, partitionKey); return UpdateOne(filter, field, value, null, cancellationToken);
} }
/// <summary> /// <inheritdoc />
/// For the entities selected by the filter, applies the update you have defined in MongoDb. public virtual bool UpdateOne<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey)
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual async Task<long> UpdateManyAsync<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
{ {
return await MongoDbUpdater.UpdateManyAsync<TDocument, TKey>(filter, updateDefinition, partitionKey); return UpdateOne(filter, field, value, partitionKey, CancellationToken.None);
} }
/// <summary> /// <inheritdoc />
/// For the entities selected by the filter, updates the property field with the given value. public virtual bool UpdateOne<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey, CancellationToken cancellationToken)
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
public virtual long UpdateMany<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
{ {
return MongoDbUpdater.UpdateMany<TDocument, TKey, TField>(filter, field, value, partitionKey); return MongoDbUpdater.UpdateOne<TDocument, TKey, TField>(filter, field, value, partitionKey, cancellationToken);
} }
/// <summary> /// <inheritdoc />
/// For the entities selected by the filter, updates the property field with the given value. public virtual async Task<bool> UpdateOneAsync<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value)
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual long UpdateMany<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
{ {
return MongoDbUpdater.UpdateMany<TDocument, TKey, TField>(filter, field, value, partitionKey); return await UpdateOneAsync(filter, field, value, null, CancellationToken.None);
} }
/// <summary> /// <inheritdoc />
/// For the entities selected by the filter, applies the update you have defined in MongoDb. public virtual async Task<bool> UpdateOneAsync<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken)
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual long UpdateMany<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
{ {
return MongoDbUpdater.UpdateMany<TDocument, TKey>(filter, updateDefinition, partitionKey); return await UpdateOneAsync(filter, field, value, null, cancellationToken);
} }
/// <summary> /// <inheritdoc />
/// For the entities selected by the filter, applies the update you have defined in MongoDb. public virtual async Task<bool> UpdateOneAsync<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey)
/// </summary> where TDocument : IDocument<TKey>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual long UpdateMany<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null) where TDocument : IDocument<TKey>
{ {
return MongoDbUpdater.UpdateMany<TDocument, TKey>(filter, updateDefinition, partitionKey); return await UpdateOneAsync(filter, field, value, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<bool> UpdateOneAsync<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey, TField>(filter, field, value, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<bool> UpdateOneAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value)
where TDocument : IDocument<TKey>
{
return await UpdateOneAsync(filter, field, value, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<bool> UpdateOneAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await UpdateOneAsync(filter, field, value, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<bool> UpdateOneAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey)
where TDocument : IDocument<TKey>
{
return await UpdateOneAsync(filter, field, value, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<bool> UpdateOneAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey, TField>(filter, field, value, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<long> UpdateManyAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value)
where TDocument : IDocument<TKey>
{
return await UpdateManyAsync(filter, field, value, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<long> UpdateManyAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await UpdateManyAsync(filter, field, value, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<long> UpdateManyAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey)
where TDocument : IDocument<TKey>
{
return await UpdateManyAsync(filter, field, value, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<long> UpdateManyAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await MongoDbUpdater.UpdateManyAsync<TDocument, TKey, TField>(filter, field, value, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<long> UpdateManyAsync<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value)
where TDocument : IDocument<TKey>
{
return await UpdateManyAsync(filter, field, value, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<long> UpdateManyAsync<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await UpdateManyAsync(filter, field, value, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<long> UpdateManyAsync<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey)
where TDocument : IDocument<TKey>
{
return await UpdateManyAsync(filter, field, value, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<long> UpdateManyAsync<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await MongoDbUpdater.UpdateManyAsync<TDocument, TKey, TField>(filter, field, value, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<long> UpdateManyAsync<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition)
where TDocument : IDocument<TKey>
{
return await UpdateManyAsync(filter, updateDefinition, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<long> UpdateManyAsync<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await UpdateManyAsync(filter, updateDefinition, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<long> UpdateManyAsync<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey)
where TDocument : IDocument<TKey>
{
return await UpdateManyAsync(filter, updateDefinition, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<long> UpdateManyAsync<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await MongoDbUpdater.UpdateManyAsync<TDocument, TKey>(filter, updateDefinition, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<long> UpdateManyAsync<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition)
where TDocument : IDocument<TKey>
{
return await UpdateManyAsync(filter, updateDefinition, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<long> UpdateManyAsync<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await UpdateManyAsync(filter, updateDefinition, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<long> UpdateManyAsync<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey)
where TDocument : IDocument<TKey>
{
return await UpdateManyAsync(filter, updateDefinition, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<long> UpdateManyAsync<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await MongoDbUpdater.UpdateManyAsync<TDocument, TKey>(filter, updateDefinition, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual long UpdateMany<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value)
where TDocument : IDocument<TKey>
{
return UpdateMany(filter, field, value, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual long UpdateMany<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return UpdateMany(filter, field, value, null, cancellationToken);
}
/// <inheritdoc />
public virtual long UpdateMany<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey)
where TDocument : IDocument<TKey>
{
return UpdateMany(filter, field, value, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual long UpdateMany<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return MongoDbUpdater.UpdateMany<TDocument, TKey, TField>(filter, field, value, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual long UpdateMany<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value)
where TDocument : IDocument<TKey>
{
return MongoDbUpdater.UpdateMany<TDocument, TKey, TField>(filter, field, value, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual long UpdateMany<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return MongoDbUpdater.UpdateMany<TDocument, TKey, TField>(filter, field, value, null, cancellationToken);
}
/// <inheritdoc />
public virtual long UpdateMany<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey)
where TDocument : IDocument<TKey>
{
return MongoDbUpdater.UpdateMany<TDocument, TKey, TField>(filter, field, value, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual long UpdateMany<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return MongoDbUpdater.UpdateMany<TDocument, TKey, TField>(filter, field, value, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual long UpdateMany<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition)
where TDocument : IDocument<TKey>
{
return UpdateMany(filter, updateDefinition, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual long UpdateMany<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return UpdateMany(filter, updateDefinition, null, cancellationToken);
}
/// <inheritdoc />
public virtual long UpdateMany<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey)
where TDocument : IDocument<TKey>
{
return UpdateMany(filter, updateDefinition, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual long UpdateMany<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return MongoDbUpdater.UpdateMany<TDocument, TKey>(filter, updateDefinition, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual long UpdateMany<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition)
where TDocument : IDocument<TKey>
{
return UpdateMany(filter, updateDefinition, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual long UpdateMany<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return UpdateMany(filter, updateDefinition, null, cancellationToken);
}
/// <inheritdoc />
public virtual long UpdateMany<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey)
where TDocument : IDocument<TKey>
{
return UpdateMany(filter, updateDefinition, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual long UpdateMany<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return MongoDbUpdater.UpdateMany<TDocument, TKey>(filter, updateDefinition, partitionKey, cancellationToken);
} }
} }
} }
@@ -1,5 +1,6 @@
using System; using System;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MongoDB.Driver; using MongoDB.Driver;
using MongoDbGenericRepository.Models; using MongoDbGenericRepository.Models;
@@ -7,27 +8,48 @@ using MongoDbGenericRepository.Models;
namespace MongoDbGenericRepository namespace MongoDbGenericRepository
{ {
/// <summary> /// <summary>
/// The base Mongo Repository Update interface. used to update documents in the collections. /// The base Mongo Repository Update interface. used to update documents in the collections.
/// </summary> /// </summary>
/// <typeparam name="TKey"></typeparam> /// <typeparam name="TKey"></typeparam>
public interface IBaseMongoRepository_Update<TKey> where TKey : IEquatable<TKey> public interface IBaseMongoRepository_Update<TKey>
where TKey : IEquatable<TKey>
{ {
/// <summary> /// <summary>
/// Asynchronously Updates a document. /// Asynchronously Updates a document.
/// </summary> /// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param> /// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
Task<bool> UpdateOneAsync<TDocument>(TDocument modifiedDocument) where TDocument : IDocument<TKey>; Task<bool> UpdateOneAsync<TDocument>(TDocument modifiedDocument)
where TDocument : IDocument<TKey>;
/// <summary> /// <summary>
/// Updates a document. /// Asynchronously Updates a document.
/// </summary> /// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param> /// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
bool UpdateOne<TDocument>(TDocument modifiedDocument) where TDocument : IDocument<TKey>; /// <param name="cancellationToken">The cancellation token.</param>
Task<bool> UpdateOneAsync<TDocument>(TDocument modifiedDocument, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary> /// <summary>
/// Takes a document you want to modify and applies the update you have defined in MongoDb. /// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
bool UpdateOne<TDocument>(TDocument modifiedDocument)
where TDocument : IDocument<TKey>;
/// <summary>
/// Updates a document.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
/// <param name="cancellationToken">The cancellation token.</param>
bool UpdateOne<TDocument>(TDocument modifiedDocument, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// Takes a document you want to modify and applies the update you have defined in MongoDb.
/// </summary> /// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="documentToModify">The document you want to modify.</param> /// <param name="documentToModify">The document you want to modify.</param>
@@ -36,7 +58,17 @@ namespace MongoDbGenericRepository
where TDocument : IDocument<TKey>; where TDocument : IDocument<TKey>;
/// <summary> /// <summary>
/// Takes a document you want to modify and applies the update you have defined in MongoDb. /// Takes a document you want to modify and applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="documentToModify">The document you want to modify.</param>
/// <param name="update">The update definition for the document.</param>
/// <param name="cancellationToken">The cancellation token.</param>
Task<bool> UpdateOneAsync<TDocument>(TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// Takes a document you want to modify and applies the update you have defined in MongoDb.
/// </summary> /// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="documentToModify">The document you want to modify.</param> /// <param name="documentToModify">The document you want to modify.</param>
@@ -45,7 +77,17 @@ namespace MongoDbGenericRepository
where TDocument : IDocument<TKey>; where TDocument : IDocument<TKey>;
/// <summary> /// <summary>
/// Updates the property field with the given value update a property field in entities. /// Takes a document you want to modify and applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="documentToModify">The document you want to modify.</param>
/// <param name="update">The update definition for the document.</param>
/// <param name="cancellationToken">The cancellation token.</param>
bool UpdateOne<TDocument>(TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// Updates the property field with the given value update a property field in entities.
/// </summary> /// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam> /// <typeparam name="TField">The type of the field.</typeparam>
@@ -56,7 +98,23 @@ namespace MongoDbGenericRepository
where TDocument : IDocument<TKey>; where TDocument : IDocument<TKey>;
/// <summary> /// <summary>
/// Updates the property field with the given value update a property field in entities. /// Updates the property field with the given value update a property field in entities.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="documentToModify">The document you want to modify.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="cancellationToken">The cancellation token.</param>
bool UpdateOne<TDocument, TField>(
TDocument documentToModify,
Expression<Func<TDocument, TField>> field,
TField value,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// Updates the property field with the given value update a property field in entities.
/// </summary> /// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam> /// <typeparam name="TField">The type of the field.</typeparam>
@@ -67,7 +125,50 @@ namespace MongoDbGenericRepository
where TDocument : IDocument<TKey>; where TDocument : IDocument<TKey>;
/// <summary> /// <summary>
/// Updates the property field with the given value update a property field in entities. /// Updates the property field with the given value update a property field in entities.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="documentToModify">The document you want to modify.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="cancellationToken">The cancellation token.</param>
Task<bool> UpdateOneAsync<TDocument, TField>(
TDocument documentToModify,
Expression<Func<TDocument, TField>> field,
TField value,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// Updates the property field with the given value update a property field in entities.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
bool UpdateOne<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value)
where TDocument : IDocument<TKey>;
/// <summary>
/// Updates the property field with the given value update a property field in entities.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="cancellationToken">The cancellation token.</param>
bool UpdateOne<TDocument, TField>(
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// Updates the property field with the given value update a property field in entities.
/// </summary> /// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam> /// <typeparam name="TField">The type of the field.</typeparam>
@@ -75,11 +176,63 @@ namespace MongoDbGenericRepository
/// <param name="field">The field selector.</param> /// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param> /// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param> /// <param name="partitionKey">The value of the partition key.</param>
bool UpdateOne<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null) bool UpdateOne<TDocument, TField>(
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey)
where TDocument : IDocument<TKey>; where TDocument : IDocument<TKey>;
/// <summary> /// <summary>
/// For the entity selected by the filter, updates the property field with the given value. /// Updates the property field with the given value update a property field in entities.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
bool UpdateOne<TDocument, TField>(
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entity selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
bool UpdateOne<TDocument, TField>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entity selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="cancellationToken">The cancellation token.</param>
bool UpdateOne<TDocument, TField>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entity selected by the filter, updates the property field with the given value.
/// </summary> /// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam> /// <typeparam name="TField">The type of the field.</typeparam>
@@ -87,23 +240,15 @@ namespace MongoDbGenericRepository
/// <param name="field">The field selector.</param> /// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param> /// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param> /// <param name="partitionKey">The partition key for the document.</param>
bool UpdateOne<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null) bool UpdateOne<TDocument, TField>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey)
where TDocument : IDocument<TKey>; where TDocument : IDocument<TKey>;
/// <summary> /// <summary>
/// Updates the property field with the given value update a property field in entities. /// For the entity selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
Task<bool> UpdateOneAsync<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entity selected by the filter, updates the property field with the given value.
/// </summary> /// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam> /// <typeparam name="TField">The type of the field.</typeparam>
@@ -111,11 +256,105 @@ namespace MongoDbGenericRepository
/// <param name="field">The field selector.</param> /// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param> /// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param> /// <param name="partitionKey">The partition key for the document.</param>
Task<bool> UpdateOneAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null) /// <param name="cancellationToken">The cancellation token.</param>
bool UpdateOne<TDocument, TField>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>; where TDocument : IDocument<TKey>;
/// <summary> /// <summary>
/// For the entities selected by the filter, updates the property field with the given value. /// Updates the property field with the given value update a property field in entities.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
Task<bool> UpdateOneAsync<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value)
where TDocument : IDocument<TKey>;
/// <summary>
/// Updates the property field with the given value update a property field in entities.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="cancellationToken">The cancellation token.</param>
Task<bool> UpdateOneAsync<TDocument, TField>(
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// Updates the property field with the given value update a property field in entities.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
Task<bool> UpdateOneAsync<TDocument, TField>(
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey)
where TDocument : IDocument<TKey>;
/// <summary>
/// Updates the property field with the given value update a property field in entities.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
Task<bool> UpdateOneAsync<TDocument, TField>(
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entity selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
Task<bool> UpdateOneAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entity selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="cancellationToken">The cancellation token.</param>
Task<bool> UpdateOneAsync<TDocument, TField>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entity selected by the filter, updates the property field with the given value.
/// </summary> /// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam> /// <typeparam name="TField">The type of the field.</typeparam>
@@ -123,43 +362,15 @@ namespace MongoDbGenericRepository
/// <param name="field">The field selector.</param> /// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param> /// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param> /// <param name="partitionKey">The partition key for the document.</param>
Task<long> UpdateManyAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null) Task<bool> UpdateOneAsync<TDocument, TField>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey)
where TDocument : IDocument<TKey>; where TDocument : IDocument<TKey>;
/// <summary> /// <summary>
/// For the entities selected by the filter, updates the property field with the given value. /// For the entity selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
Task<long> UpdateManyAsync<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
Task<long> UpdateManyAsync<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
Task<long> UpdateManyAsync<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary> /// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam> /// <typeparam name="TField">The type of the field.</typeparam>
@@ -167,11 +378,105 @@ namespace MongoDbGenericRepository
/// <param name="field">The field selector.</param> /// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param> /// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param> /// <param name="partitionKey">The partition key for the document.</param>
long UpdateMany<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null) /// <param name="cancellationToken">The cancellation token.</param>
Task<bool> UpdateOneAsync<TDocument, TField>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>; where TDocument : IDocument<TKey>;
/// <summary> /// <summary>
/// For the entities selected by the filter, updates the property field with the given value. /// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
Task<long> UpdateManyAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="cancellationToken">The cancellation token.</param>
Task<long> UpdateManyAsync<TDocument, TField>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
Task<long> UpdateManyAsync<TDocument, TField>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
/// <param name="cancellationToken">The cancellation token.</param>
Task<long> UpdateManyAsync<TDocument, TField>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
Task<long> UpdateManyAsync<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="cancellationToken">The cancellation token.</param>
Task<long> UpdateManyAsync<TDocument, TField>(
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary> /// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam> /// <typeparam name="TField">The type of the field.</typeparam>
@@ -179,27 +484,339 @@ namespace MongoDbGenericRepository
/// <param name="field">The field selector.</param> /// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param> /// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param> /// <param name="partitionKey">The value of the partition key.</param>
long UpdateMany<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null) Task<long> UpdateManyAsync<TDocument, TField>(
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey)
where TDocument : IDocument<TKey>; where TDocument : IDocument<TKey>;
/// <summary> /// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb. /// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
Task<long> UpdateManyAsync<TDocument, TField>(
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
Task<long> UpdateManyAsync<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="cancellationToken">The cancellation token.</param>
Task<long> UpdateManyAsync<TDocument>(
FilterDefinition<TDocument> filter,
UpdateDefinition<TDocument> updateDefinition,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary> /// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param> /// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param> /// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param> /// <param name="partitionKey">The value of the partition key.</param>
long UpdateMany<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null) Task<long> UpdateManyAsync<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey)
where TDocument : IDocument<TKey>; where TDocument : IDocument<TKey>;
/// <summary> /// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb. /// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary> /// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param> /// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param> /// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param> /// <param name="partitionKey">The value of the partition key.</param>
long UpdateMany<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null) /// <param name="cancellationToken">The cancellation token.</param>
Task<long> UpdateManyAsync<TDocument>(
FilterDefinition<TDocument> filter,
UpdateDefinition<TDocument> updateDefinition,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
Task<long> UpdateManyAsync<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="cancellationToken">The cancellation token.</param>
Task<long> UpdateManyAsync<TDocument>(
Expression<Func<TDocument, bool>> filter,
UpdateDefinition<TDocument> updateDefinition,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
Task<long> UpdateManyAsync<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
Task<long> UpdateManyAsync<TDocument>(
Expression<Func<TDocument, bool>> filter,
UpdateDefinition<TDocument> updateDefinition,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
long UpdateMany<TDocument, TField>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="cancellationToken">The cancellation token.</param>
long UpdateMany<TDocument, TField>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
long UpdateMany<TDocument, TField>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
/// <param name="cancellationToken">The cancellation token.</param>
long UpdateMany<TDocument, TField>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
long UpdateMany<TDocument, TField>(
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="cancellationToken">The cancellation token.</param>
long UpdateMany<TDocument, TField>(
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
long UpdateMany<TDocument, TField>(
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
long UpdateMany<TDocument, TField>(
FilterDefinition<TDocument> filter,
Expression<Func<TDocument, TField>> field,
TField value,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
long UpdateMany<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="cancellationToken">The cancellation token.</param>
long UpdateMany<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
long UpdateMany<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
long UpdateMany<TDocument>(
FilterDefinition<TDocument> filter,
UpdateDefinition<TDocument> updateDefinition,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
long UpdateMany<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="cancellationToken">The cancellation token.</param>
long UpdateMany<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
long UpdateMany<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
long UpdateMany<TDocument>(
Expression<Func<TDocument, bool>> filter,
UpdateDefinition<TDocument> updateDefinition,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>; where TDocument : IDocument<TKey>;
} }
} }