diff --git a/MongoDbGenericRepository/Abstractions/IBaseMongoRepository.cs b/MongoDbGenericRepository/Abstractions/IBaseMongoRepository.cs
index ead6f9f..72009fa 100644
--- a/MongoDbGenericRepository/Abstractions/IBaseMongoRepository.cs
+++ b/MongoDbGenericRepository/Abstractions/IBaseMongoRepository.cs
@@ -25,7 +25,11 @@ namespace MongoDbGenericRepository
/// The number of documents you want to skip. Default value is 0.
/// The number of documents you want to take. Default value is 50.
/// An optional partition key.
- Task> GetPaginatedAsync(Expression> filter, int skipNumber = 0, int takeNumber = 50, string partitionKey = null)
+ Task> GetPaginatedAsync(
+ Expression> filter,
+ int skipNumber = 0,
+ int takeNumber = 50,
+ string partitionKey = null)
where TDocument : IDocument;
///
@@ -37,7 +41,11 @@ namespace MongoDbGenericRepository
/// The number of documents you want to skip. Default value is 0.
/// The number of documents you want to take. Default value is 50.
/// An optional partition key.
- Task> GetPaginatedAsync(Expression> filter, int skipNumber = 0, int takeNumber = 50, string partitionKey = null)
+ Task> GetPaginatedAsync(
+ Expression> filter,
+ int skipNumber = 0,
+ int takeNumber = 50,
+ string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
@@ -49,7 +57,10 @@ namespace MongoDbGenericRepository
///
///
///
- Task GetAndUpdateOne(FilterDefinition filter, UpdateDefinition update, FindOneAndUpdateOptions options)
+ Task GetAndUpdateOne(
+ FilterDefinition filter,
+ UpdateDefinition update,
+ FindOneAndUpdateOptions options)
where TDocument : IDocument;
///
@@ -61,7 +72,10 @@ namespace MongoDbGenericRepository
///
///
///
- Task GetAndUpdateOne(FilterDefinition filter, UpdateDefinition update, FindOneAndUpdateOptions options)
+ Task GetAndUpdateOne(
+ FilterDefinition filter,
+ UpdateDefinition update,
+ FindOneAndUpdateOptions options)
where TDocument : IDocument
where TKey : IEquatable;
}
diff --git a/MongoDbGenericRepository/Abstractions/IBaseMongoRepository_Update.cs b/MongoDbGenericRepository/Abstractions/IBaseMongoRepository_Update.cs
index 86ec936..10dc3c2 100644
--- a/MongoDbGenericRepository/Abstractions/IBaseMongoRepository_Update.cs
+++ b/MongoDbGenericRepository/Abstractions/IBaseMongoRepository_Update.cs
@@ -2,6 +2,7 @@
using MongoDbGenericRepository.Models;
using System;
using System.Linq.Expressions;
+using System.Threading;
using System.Threading.Tasks;
namespace MongoDbGenericRepository
@@ -21,6 +22,17 @@ namespace MongoDbGenericRepository
where TDocument : IDocument
where TKey : IEquatable;
+ ///
+ /// Asynchronously Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The document with the modifications you want to persist.
+ /// The cancellation token.
+ Task UpdateOneAsync(TDocument modifiedDocument, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
///
/// Updates a document.
///
@@ -31,6 +43,17 @@ namespace MongoDbGenericRepository
where TDocument : IDocument
where TKey : IEquatable;
+ ///
+ /// Updates a document.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The document with the modifications you want to persist.
+ /// The cancellation token.
+ bool UpdateOne(TDocument modifiedDocument, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
///
/// Takes a document you want to modify and applies the update you have defined in MongoDb.
///
@@ -42,6 +65,18 @@ namespace MongoDbGenericRepository
where TDocument : IDocument
where TKey : IEquatable;
+ ///
+ /// Takes a document you want to modify and applies the update you have defined in MongoDb.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The document you want to modify.
+ /// The update definition for the document.
+ /// The cancellation token.
+ Task UpdateOneAsync(TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
///
/// Takes a document you want to modify and applies the update you have defined in MongoDb.
///
@@ -53,6 +88,45 @@ namespace MongoDbGenericRepository
where TDocument : IDocument
where TKey : IEquatable;
+ ///
+ /// Takes a document you want to modify and applies the update you have defined in MongoDb.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The document you want to modify.
+ /// The update definition for the document.
+ /// The cancellation token.
+ bool UpdateOne(TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entity selected by the filter, updates the property field with the given value..
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ bool UpdateOne(Expression> filter, Expression> field, TField value)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entity selected by the filter, updates the property field with the given value..
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The cancellation token.
+ bool UpdateOne(Expression> filter, Expression> field, TField value, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
///
/// For the entity selected by the filter, updates the property field with the given value..
///
@@ -63,7 +137,22 @@ namespace MongoDbGenericRepository
/// The field selector.
/// The new value of the property field.
/// The partition key for the document.
- bool UpdateOne(Expression> filter, Expression> field, TField value, string partitionKey = null)
+ bool UpdateOne(Expression> filter, Expression> field, TField value, string partitionKey)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entity selected by the filter, updates the property field with the given value..
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The partition key for the document.
+ /// The cancellation token.
+ bool UpdateOne(Expression> filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
@@ -80,6 +169,47 @@ namespace MongoDbGenericRepository
where TDocument : IDocument
where TKey : IEquatable;
+ ///
+ /// Updates the property field with the given value update a property field in entities.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document you want to modify.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The cancellation token.
+ Task UpdateOneAsync(TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entity selected by the filter, updates the property field with the given value.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ Task UpdateOneAsync(Expression> filter, Expression> field, TField value)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entity selected by the filter, updates the property field with the given value.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The cancellation token.
+ Task UpdateOneAsync(Expression> filter, Expression> field, TField value, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
///
/// For the entity selected by the filter, updates the property field with the given value.
///
@@ -90,7 +220,22 @@ namespace MongoDbGenericRepository
/// The field selector.
/// The new value of the property field.
/// The partition key for the document.
- Task UpdateOneAsync(Expression> filter, Expression> field, TField value, string partitionKey = null)
+ Task UpdateOneAsync(Expression> filter, Expression> field, TField value, string partitionKey)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entity selected by the filter, updates the property field with the given value.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The partition key for the document.
+ /// The cancellation token.
+ Task UpdateOneAsync(Expression> filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
@@ -107,6 +252,20 @@ namespace MongoDbGenericRepository
where TDocument : IDocument
where TKey : IEquatable;
+ ///
+ /// Updates the property field with the given value update a property field in entities.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document you want to modify.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The cancellation token.
+ bool UpdateOne(TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
///
/// Updates the property field with the given value update a property field in entities.
///
@@ -116,8 +275,21 @@ namespace MongoDbGenericRepository
/// The document filter.
/// The field selector.
/// The new value of the property field.
- /// The value of the partition key.
- Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey = null)
+ Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates the property field with the given value update a property field in entities.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The cancellation token.
+ Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
@@ -131,7 +303,105 @@ namespace MongoDbGenericRepository
/// The field selector.
/// The new value of the property field.
/// The value of the partition key.
- bool UpdateOne(FilterDefinition filter, Expression> field, TField value, string partitionKey = null)
+ Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates the property field with the given value update a property field in entities.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The value of the partition key.
+ /// The cancellation token.
+ Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates the property field with the given value update a property field in entities.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ bool UpdateOne(FilterDefinition filter, Expression> field, TField value)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates the property field with the given value update a property field in entities.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The cancellation token.
+ bool UpdateOne(FilterDefinition filter, Expression> field, TField value, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates the property field with the given value update a property field in entities.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The value of the partition key.
+ bool UpdateOne(FilterDefinition filter, Expression> field, TField value, string partitionKey)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// Updates the property field with the given value update a property field in entities.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The value of the partition key.
+ /// The cancellation token.
+ bool UpdateOne(FilterDefinition filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entities selected by the filter, updates the property field with the given value.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ Task UpdateManyAsync(Expression> filter, Expression> field, TField value)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entities selected by the filter, updates the property field with the given value.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The cancellation token.
+ Task UpdateManyAsync(Expression> filter, Expression> field, TField value, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
@@ -145,45 +415,7 @@ namespace MongoDbGenericRepository
/// The field selector.
/// The new value of the property field.
/// The partition key for the document.
- Task UpdateManyAsync(Expression> filter, Expression> field, TField value, string partitionKey = null)
- where TDocument : IDocument
- where TKey : IEquatable;
-
- ///
- /// For the entities selected by the filter, updates the property field with the given value.
- ///
- /// The type representing a Document.
- /// The type of the primary key for a Document.
- /// The type of the field.
- /// The document filter.
- /// The field selector.
- /// The new value of the property field.
- /// The value of the partition key.
- Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey = null)
- where TDocument : IDocument
- where TKey : IEquatable;
-
- ///
- /// For the entities selected by the filter, applies the update you have defined in MongoDb.
- ///
- /// The type representing a Document.
- /// The type of the primary key for a Document.
- /// The document filter.
- /// The update definition to apply.
- /// The value of the partition key.
- Task UpdateManyAsync(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey = null)
- where TDocument : IDocument
- where TKey : IEquatable;
-
- ///
- /// For the entities selected by the filter, applies the update you have defined in MongoDb.
- ///
- /// The type representing a Document.
- /// The type of the primary key for a Document.
- /// The document filter.
- /// The update definition to apply.
- /// The value of the partition key.
- Task UpdateManyAsync(Expression> filter, UpdateDefinition updateDefinition, string partitionKey = null)
+ Task UpdateManyAsync(Expression> filter, Expression> field, TField value, string partitionKey)
where TDocument : IDocument
where TKey : IEquatable;
@@ -197,7 +429,35 @@ namespace MongoDbGenericRepository
/// The field selector.
/// The new value of the property field.
/// The partition key for the document.
- long UpdateMany(Expression> filter, Expression> field, TField value, string partitionKey = null)
+ /// The cancellation token.
+ Task UpdateManyAsync(Expression> filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entities selected by the filter, updates the property field with the given value.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entities selected by the filter, updates the property field with the given value.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The cancellation token.
+ Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value, CancellationToken cancellationToken)
where TDocument : IDocument
where TKey : IEquatable;
@@ -211,7 +471,45 @@ namespace MongoDbGenericRepository
/// The field selector.
/// The new value of the property field.
/// The value of the partition key.
- long UpdateMany(FilterDefinition filter, Expression> field, TField value, string partitionKey = null)
+ Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entities selected by the filter, updates the property field with the given value.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The value of the partition key.
+ /// The cancellation token.
+ Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entities selected by the filter, applies the update you have defined in MongoDb.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The document filter.
+ /// The update definition to apply.
+ Task UpdateManyAsync