diff --git a/MongoDbGenericRepository/Abstractions/IBaseMongoRepository_Update_ClientSession.cs b/MongoDbGenericRepository/Abstractions/IBaseMongoRepository_Update_ClientSession.cs
index 9e9223b..60dc065 100644
--- a/MongoDbGenericRepository/Abstractions/IBaseMongoRepository_Update_ClientSession.cs
+++ b/MongoDbGenericRepository/Abstractions/IBaseMongoRepository_Update_ClientSession.cs
@@ -12,6 +12,38 @@ namespace MongoDbGenericRepository.DataAccess.Update
///
public interface IBaseMongoRepository_Update_ClientSession
{
+
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field to update.
+ /// The client session.
+ /// The filter for the update.
+ /// The field to update.
+ /// The value of the field.
+ /// A boolean value indicating success.
+ bool UpdateOne(IClientSessionHandle session, Expression> filter, Expression> field, TField value)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field to update.
+ /// The client session.
+ /// The filter for the update.
+ /// The field to update.
+ /// The value of the field.
+ /// The optional cancellation token.
+ /// A boolean value indicating success.
+ bool UpdateOne(IClientSessionHandle session, Expression> filter, Expression> field, TField value, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
///
/// Updates a document.
///
@@ -23,9 +55,8 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// The field to update.
/// The value of the field.
/// The optional partition key.
- /// The optional cancellation token.
/// A boolean value indicating success.
- bool UpdateOne(IClientSessionHandle session, Expression> filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken))
+ bool UpdateOne(IClientSessionHandle session, Expression> filter, Expression> field, TField value, string partitionKey)
where TDocument : IDocument
where TKey : IEquatable;
@@ -42,7 +73,86 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// The optional partition key.
/// The optional cancellation token.
/// A boolean value indicating success.
- bool UpdateOne(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken))
+ bool UpdateOne(IClientSessionHandle session, Expression> filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field to update.
+ /// The client session.
+ /// The filter for the update.
+ /// The field to update.
+ /// The value of the field.
+ /// A boolean value indicating success.
+ bool UpdateOne(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field to update.
+ /// The client session.
+ /// The filter for the update.
+ /// The field to update.
+ /// The value of the field.
+ /// The optional cancellation token.
+ /// A boolean value indicating success.
+ bool UpdateOne(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field to update.
+ /// The client session.
+ /// The filter for the update.
+ /// The field to update.
+ /// The value of the field.
+ /// The optional partition key.
+ /// A boolean value indicating success.
+ bool UpdateOne(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, string partitionKey)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field to update.
+ /// The client session.
+ /// The filter for the update.
+ /// The field to update.
+ /// The value of the field.
+ /// The optional partition key.
+ /// The optional cancellation token.
+ /// A boolean value indicating success.
+ bool UpdateOne(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field to update.
+ /// The client session.
+ /// The document to modify.
+ /// The field to update.
+ /// The value of the field.
+ /// A boolean value indicating success.
+ bool UpdateOne(IClientSessionHandle session, TDocument documentToModify, Expression> field, TField value)
where TDocument : IDocument
where TKey : IEquatable;
@@ -58,7 +168,19 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// The value of the field.
/// The optional cancellation token.
/// A boolean value indicating success.
- bool UpdateOne(IClientSessionHandle session, TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken = default(CancellationToken))
+ bool UpdateOne(IClientSessionHandle session, TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The client session.
+ /// The document with the modifications you want to persist.
+ /// A boolean value indicating success.
+ bool UpdateOne(IClientSessionHandle session, TDocument modifiedDocument)
where TDocument : IDocument
where TKey : IEquatable;
@@ -71,7 +193,20 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// The document with the modifications you want to persist.
/// The optional cancellation token.
/// A boolean value indicating success.
- bool UpdateOne(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken))
+ bool UpdateOne(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The client session.
+ /// The document to modify.
+ /// The update definition.
+ /// A boolean value indicating success.
+ bool UpdateOne(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition update)
where TDocument : IDocument
where TKey : IEquatable;
@@ -85,7 +220,54 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// The update definition.
/// The optional cancellation token.
/// A boolean value indicating success.
- bool UpdateOne(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken = default(CancellationToken))
+ bool UpdateOne(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field to update.
+ /// The client session.
+ /// The filter for the update.
+ /// The field to update.
+ /// The value of the field.
+ /// A boolean value indicating success.
+ Task UpdateOneAsync(IClientSessionHandle session, Expression> filter, Expression> field, TField value)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field to update.
+ /// The client session.
+ /// The filter for the update.
+ /// The field to update.
+ /// The value of the field.
+ /// The optional cancellation token.
+ /// A boolean value indicating success.
+ Task UpdateOneAsync(IClientSessionHandle session, Expression> filter, Expression> field, TField value, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field to update.
+ /// The client session.
+ /// The filter for the update.
+ /// The field to update.
+ /// The value of the field.
+ /// The optional partition key.
+ /// A boolean value indicating success.
+ Task UpdateOneAsync(IClientSessionHandle session, Expression> filter, Expression> field, TField value, string partitionKey)
where TDocument : IDocument
where TKey : IEquatable;
@@ -102,7 +284,54 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// The optional partition key.
/// The optional cancellation token.
/// A boolean value indicating success.
- Task UpdateOneAsync(IClientSessionHandle session, Expression> filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken))
+ Task UpdateOneAsync(IClientSessionHandle session, Expression> filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field to update.
+ /// The client session.
+ /// The filter for the update.
+ /// The field to update.
+ /// The value of the field.
+ ///
+ Task UpdateOneAsync(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field to update.
+ /// The client session.
+ /// The filter for the update.
+ /// The field to update.
+ /// The value of the field.
+ /// The optional cancellation token.
+ ///
+ Task UpdateOneAsync(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field to update.
+ /// The client session.
+ /// The filter for the update.
+ /// The field to update.
+ /// The value of the field.
+ /// The optional partition key.
+ ///
+ Task UpdateOneAsync(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, string partitionKey)
where TDocument : IDocument
where TKey : IEquatable;
@@ -119,7 +348,7 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// The optional partition key.
/// The optional cancellation token.
///
- Task UpdateOneAsync(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken))
+ Task UpdateOneAsync(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
@@ -129,13 +358,40 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// The type representing a Document.
/// The type of the primary key for a Document.
/// The type of the field to update.
- /// The client session.
+ /// The client session.
+ /// The document to modify.
+ /// The field to update.
+ /// The value of the field.
+ /// A boolean value indicating success.
+ Task UpdateOneAsync(IClientSessionHandle session, TDocument documentToModify, Expression> field, TField value)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field to update.
+ /// The client session.
/// The document to modify.
/// The field to update.
/// The value of the field.
/// The optional cancellation token.
/// A boolean value indicating success.
- Task UpdateOneAsync(IClientSessionHandle session, TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken = default(CancellationToken))
+ Task UpdateOneAsync(IClientSessionHandle session, TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The client session.
+ /// The document with the modifications you want to persist.
+ /// A boolean value indicating success.
+ Task UpdateOneAsync(IClientSessionHandle session, TDocument modifiedDocument)
where TDocument : IDocument
where TKey : IEquatable;
@@ -148,7 +404,20 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// The document with the modifications you want to persist.
/// The optional cancellation token.
/// A boolean value indicating success.
- Task UpdateOneAsync(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken))
+ Task UpdateOneAsync(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The client session.
+ /// The document to modify.
+ /// The update definition.
+ /// A boolean value indicating success.
+ Task UpdateOneAsync(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition update)
where TDocument : IDocument
where TKey : IEquatable;
@@ -162,7 +431,7 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// The update definition.
/// The optional cancellation token.
/// A boolean value indicating success.
- Task UpdateOneAsync(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken = default(CancellationToken))
+ Task UpdateOneAsync(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
}
diff --git a/MongoDbGenericRepository/BaseMongoRepository.Update.ClientSession.cs b/MongoDbGenericRepository/BaseMongoRepository.Update.ClientSession.cs
index aa661b0..ef4b774 100644
--- a/MongoDbGenericRepository/BaseMongoRepository.Update.ClientSession.cs
+++ b/MongoDbGenericRepository/BaseMongoRepository.Update.ClientSession.cs
@@ -1,197 +1,350 @@
-using MongoDB.Driver;
-using MongoDbGenericRepository.DataAccess.Update;
-using MongoDbGenericRepository.Models;
-using System;
+using System;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
+using MongoDB.Driver;
+using MongoDbGenericRepository.DataAccess.Update;
+using MongoDbGenericRepository.Models;
namespace MongoDbGenericRepository
{
public abstract partial class BaseMongoRepository : IBaseMongoRepository_Update_ClientSession
{
- ///
- /// Updates a document.
- ///
- /// The type representing a Document.
- /// The type of the primary key for a Document.
- /// The client session.
- /// The document with the modifications you want to persist.
- /// The optional cancellation token.
- /// A boolean value indicating success.
- public virtual async Task UpdateOneAsync(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken))
+ ///
+ public virtual async Task UpdateOneAsync(IClientSessionHandle session, TDocument modifiedDocument)
+ where TDocument : IDocument
+ where TKey : IEquatable
+ {
+ return await UpdateOneAsync(session, modifiedDocument, CancellationToken.None);
+ }
+
+ ///
+ public virtual async Task UpdateOneAsync(
+ IClientSessionHandle session,
+ TDocument modifiedDocument,
+ CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable
{
return await MongoDbUpdater.UpdateOneAsync(session, modifiedDocument, cancellationToken);
}
- ///
- /// Updates a document.
- ///
- /// The type representing a Document.
- /// The type of the primary key for a Document.
- /// The client session.
- /// The document with the modifications you want to persist.
- /// The optional cancellation token.
- /// A boolean value indicating success.
- public virtual bool UpdateOne(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken))
+ ///
+ public virtual bool UpdateOne(IClientSessionHandle session, TDocument modifiedDocument)
+ where TDocument : IDocument
+ where TKey : IEquatable
+ {
+ return UpdateOne(session, modifiedDocument, CancellationToken.None);
+ }
+
+ ///
+ public virtual bool UpdateOne(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable
{
return MongoDbUpdater.UpdateOne(session, modifiedDocument, cancellationToken);
}
- ///
- /// Updates a document.
- ///
- /// The type representing a Document.
- /// The type of the primary key for a Document.
- /// The client session.
- /// The document to modify.
- /// The update definition.
- /// The optional cancellation token.
- /// A boolean value indicating success.
- public virtual async Task UpdateOneAsync(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken = default(CancellationToken))
+ ///
+ public virtual async Task UpdateOneAsync(
+ IClientSessionHandle session,
+ TDocument documentToModify,
+ UpdateDefinition update)
+ where TDocument : IDocument
+ where TKey : IEquatable
+ {
+ return await UpdateOneAsync(session, documentToModify, update, CancellationToken.None);
+ }
+
+ ///
+ public virtual async Task UpdateOneAsync(
+ IClientSessionHandle session,
+ TDocument documentToModify,
+ UpdateDefinition update,
+ CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable
{
return await MongoDbUpdater.UpdateOneAsync(session, documentToModify, update, cancellationToken);
}
- ///
- /// Updates a document.
- ///
- /// The type representing a Document.
- /// The type of the primary key for a Document.
- /// The client session.
- /// The document to modify.
- /// The update definition.
- /// The optional cancellation token.
- /// A boolean value indicating success.
- public virtual bool UpdateOne(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken = default(CancellationToken))
+ ///
+ public virtual bool UpdateOne(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition update)
+ where TDocument : IDocument
+ where TKey : IEquatable
+ {
+ return UpdateOne(session, documentToModify, update, CancellationToken.None);
+ }
+
+ ///
+ public virtual bool UpdateOne(
+ IClientSessionHandle session,
+ TDocument documentToModify,
+ UpdateDefinition update,
+ CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable
{
return MongoDbUpdater.UpdateOne(session, documentToModify, update, cancellationToken);
}
- ///
- /// Updates a document.
- ///
- /// The type representing a Document.
- /// The type of the primary key for a Document.
- /// The type of the field to update.
- /// The client session.
- /// The document to modify.
- /// The field to update.
- /// The value of the field.
- /// The optional cancellation token.
- /// A boolean value indicating success.
- public virtual async Task UpdateOneAsync(IClientSessionHandle session, TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken = default(CancellationToken))
+ ///
+ public virtual async Task UpdateOneAsync(
+ IClientSessionHandle session,
+ TDocument documentToModify,
+ Expression> field,
+ TField value)
+ where TDocument : IDocument
+ where TKey : IEquatable
+ {
+ return await UpdateOneAsync(session, documentToModify, field, value, CancellationToken.None);
+ }
+
+ ///
+ public virtual async Task UpdateOneAsync(
+ IClientSessionHandle session,
+ TDocument documentToModify,
+ Expression> field,
+ TField value,
+ CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable
{
return await MongoDbUpdater.UpdateOneAsync(session, documentToModify, field, value, cancellationToken);
}
- ///
- /// Updates a document.
- ///
- /// The type representing a Document.
- /// The type of the primary key for a Document.
- /// The type of the field to update.
- /// The client session.
- /// The document to modify.
- /// The field to update.
- /// The value of the field.
- /// The optional cancellation token.
- /// A boolean value indicating success.
- public virtual bool UpdateOne(IClientSessionHandle session, TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken = default(CancellationToken))
+ ///
+ public virtual bool UpdateOne(
+ IClientSessionHandle session,
+ TDocument documentToModify,
+ Expression> field,
+ TField value)
+ where TDocument : IDocument
+ where TKey : IEquatable
+ {
+ return UpdateOne(session, documentToModify, field, value, CancellationToken.None);
+ }
+
+ ///
+ public virtual bool UpdateOne(
+ IClientSessionHandle session,
+ TDocument documentToModify,
+ Expression> field,
+ TField value,
+ CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable
{
return MongoDbUpdater.UpdateOne(session, documentToModify, field, value, cancellationToken);
}
- ///
- /// Updates a document.
- ///
- /// The type representing a Document.
- /// The type of the primary key for a Document.
- /// The type of the field to update.
- /// The client session.
- /// The filter for the update.
- /// The field to update.
- /// The value of the field.
- /// The optional partition key.
- /// The optional cancellation token.
- /// A boolean value indicating success.
- public virtual async Task UpdateOneAsync(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken))
+ ///
+ public virtual async Task UpdateOneAsync(
+ IClientSessionHandle session,
+ FilterDefinition filter,
+ Expression> field,
+ TField value)
+ where TDocument : IDocument
+ where TKey : IEquatable
+ {
+ return await UpdateOneAsync(session, filter, field, value, null, CancellationToken.None);
+ }
+
+ ///
+ public virtual async Task UpdateOneAsync(
+ IClientSessionHandle session,
+ FilterDefinition filter,
+ Expression