From 26b71ff76e5782fed8cb21c71e7c20fa73663510 Mon Sep 17 00:00:00 2001 From: Sean Garrett Date: Thu, 6 Jul 2023 13:00:55 +0100 Subject: [PATCH] reformatting --- .../Abstractions/IBaseMongoRepository.cs | 22 +- .../IBaseMongoRepository_Update.cs | 653 ++++++++++++++++-- ...aseMongoRepository_Update_ClientSession.cs | 209 ++++-- .../Abstractions/IBaseReadOnlyRepository.cs | 291 ++++++-- .../IReadOnlyMongoRepository.TKey.cs | 253 +++++-- .../Abstractions/IReadOnlyMongoRepository.cs | 3 +- .../BaseMongoRepository.Index.cs | 162 ++++- .../BaseMongoRepository.Main.cs | 121 ++-- .../BaseMongoRepository.Update.cs | 536 +++++++++++--- .../DataAccess/Read/IMongoDbReader.cs | 265 ++++--- .../DataAccess/Read/MongoDbReader.GroupBy.cs | 5 +- .../DataAccess/Update/IMongoDbUpdater.cs | 205 ++++-- .../Update/MongoDbUpdater.ClientSession.cs | 92 ++- .../DataAccess/Update/MongoDbUpdater.cs | 16 +- .../IBaseMongoRepository.Create.cs | 36 +- .../IBaseMongoRepository.Delete.cs | 1 - .../IBaseMongoRepository.Index.cs | 362 ++++++---- .../BaseMongoRepository.TKey.Delete.cs | 34 +- .../BaseMongoRepository.TKey.Index.cs | 54 +- .../BaseMongoRepository.TKey.Main.cs | 30 +- .../BaseMongoRepository.TKey.ReadOnly.cs | 20 +- .../BaseMongoRepository.TKey.Update.cs | 260 +++++-- .../IBaseMongoRepository.TKey.Delete.cs | 50 +- .../IBaseMongoRepository.TKey.Index.cs | 341 +++++---- 24 files changed, 3041 insertions(+), 980 deletions(-) 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(FilterDefinition filter, UpdateDefinition updateDefinition) + 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 cancellation token. + Task UpdateManyAsync(FilterDefinition filter, UpdateDefinition updateDefinition, CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -223,7 +521,7 @@ namespace MongoDbGenericRepository /// The document filter. /// The update definition to apply. /// The value of the partition key. - long UpdateMany(Expression> filter, UpdateDefinition updateDefinition, string partitionKey = null) + Task UpdateManyAsync(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey) where TDocument : IDocument where TKey : IEquatable; @@ -235,8 +533,265 @@ namespace MongoDbGenericRepository /// The document filter. /// The update definition to apply. /// The value of the partition key. - long UpdateMany(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey = null) + /// The cancellation token. + Task UpdateManyAsync(FilterDefinition filter, UpdateDefinition updateDefinition, 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(Expression> filter, UpdateDefinition updateDefinition) + 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 cancellation token. + Task UpdateManyAsync(Expression> filter, UpdateDefinition updateDefinition, 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. + /// The value of the partition key. + Task UpdateManyAsync(Expression> filter, UpdateDefinition updateDefinition, string partitionKey) + 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. + /// The cancellation token. + Task UpdateManyAsync(Expression> filter, UpdateDefinition updateDefinition, 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. + long UpdateMany(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. + long UpdateMany(Expression> filter, Expression> field, TField value, 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. + /// The partition key for the document. + long UpdateMany(Expression> 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 partition key for the document. + /// The cancellation token. + long UpdateMany(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. + long UpdateMany(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. + long UpdateMany(FilterDefinition filter, Expression> field, TField value, 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. + /// The value of the partition key. + long UpdateMany(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. + long UpdateMany(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. + long UpdateMany(Expression> filter, UpdateDefinition updateDefinition) + 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 cancellation token. + long UpdateMany(Expression> filter, UpdateDefinition updateDefinition, 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. + /// The value of the partition key. + long UpdateMany(Expression> filter, UpdateDefinition updateDefinition, string partitionKey) + 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. + /// The cancellation token. + long UpdateMany(Expression> filter, UpdateDefinition updateDefinition, 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. + long UpdateMany(FilterDefinition filter, UpdateDefinition updateDefinition) + 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 cancellation token. + long UpdateMany(FilterDefinition filter, UpdateDefinition updateDefinition, 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. + /// The value of the partition key. + long UpdateMany(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey) + 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. + /// The cancellation token. + long UpdateMany(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey, CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; } -} +} \ No newline at end of file diff --git a/MongoDbGenericRepository/Abstractions/IBaseMongoRepository_Update_ClientSession.cs b/MongoDbGenericRepository/Abstractions/IBaseMongoRepository_Update_ClientSession.cs index 60dc065..13cd40f 100644 --- a/MongoDbGenericRepository/Abstractions/IBaseMongoRepository_Update_ClientSession.cs +++ b/MongoDbGenericRepository/Abstractions/IBaseMongoRepository_Update_ClientSession.cs @@ -8,13 +8,12 @@ using MongoDbGenericRepository.Models; namespace MongoDbGenericRepository.DataAccess.Update { /// - /// The IBaseMongoRepository_Update_ClientSession interface exposing update functionality with a IClientSessionHandle. + /// The IBaseMongoRepository_Update_ClientSession interface exposing update functionality with a IClientSessionHandle. /// public interface IBaseMongoRepository_Update_ClientSession { - /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -24,12 +23,16 @@ namespace MongoDbGenericRepository.DataAccess.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) + bool UpdateOne( + IClientSessionHandle session, + Expression> filter, + Expression> field, + TField value) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -40,12 +43,17 @@ namespace MongoDbGenericRepository.DataAccess.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) + bool UpdateOne( + IClientSessionHandle session, + Expression> filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -56,12 +64,17 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The value of the field. /// The optional partition key. /// A boolean value indicating success. - bool UpdateOne(IClientSessionHandle session, Expression> filter, Expression> field, TField value, string partitionKey) + bool UpdateOne( + IClientSessionHandle session, + Expression> filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -73,12 +86,18 @@ namespace MongoDbGenericRepository.DataAccess.Update /// 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, CancellationToken cancellationToken) + bool UpdateOne( + IClientSessionHandle session, + Expression> filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -88,12 +107,16 @@ namespace MongoDbGenericRepository.DataAccess.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) + bool UpdateOne( + IClientSessionHandle session, + FilterDefinition filter, + Expression> field, + TField value) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -104,12 +127,17 @@ namespace MongoDbGenericRepository.DataAccess.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) + bool UpdateOne( + IClientSessionHandle session, + FilterDefinition filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -120,12 +148,17 @@ namespace MongoDbGenericRepository.DataAccess.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) + bool UpdateOne( + IClientSessionHandle session, + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -137,12 +170,18 @@ 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, CancellationToken cancellationToken) + bool UpdateOne( + IClientSessionHandle session, + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -152,12 +191,16 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The field to update. /// The value of the field. /// A boolean value indicating success. - bool UpdateOne(IClientSessionHandle session, TDocument documentToModify, Expression> field, TField value) + bool UpdateOne( + IClientSessionHandle session, + TDocument documentToModify, + Expression> field, + TField value) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -168,12 +211,17 @@ 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) + bool UpdateOne( + IClientSessionHandle session, + TDocument documentToModify, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -185,7 +233,7 @@ namespace MongoDbGenericRepository.DataAccess.Update where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -198,7 +246,7 @@ namespace MongoDbGenericRepository.DataAccess.Update where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -211,7 +259,7 @@ namespace MongoDbGenericRepository.DataAccess.Update where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -220,12 +268,16 @@ 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) + bool UpdateOne( + IClientSessionHandle session, + TDocument documentToModify, + UpdateDefinition update, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -235,12 +287,16 @@ namespace MongoDbGenericRepository.DataAccess.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) + Task UpdateOneAsync( + IClientSessionHandle session, + Expression> filter, + Expression> field, + TField value) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -251,12 +307,17 @@ namespace MongoDbGenericRepository.DataAccess.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) + Task UpdateOneAsync( + IClientSessionHandle session, + Expression> filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -267,12 +328,17 @@ namespace MongoDbGenericRepository.DataAccess.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) + Task UpdateOneAsync( + IClientSessionHandle session, + Expression> filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -284,12 +350,18 @@ 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, CancellationToken cancellationToken) + Task UpdateOneAsync( + IClientSessionHandle session, + Expression> filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -299,12 +371,16 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The field to update. /// The value of the field. /// - Task UpdateOneAsync(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value) + Task UpdateOneAsync( + IClientSessionHandle session, + FilterDefinition filter, + Expression> field, + TField value) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -315,12 +391,17 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The value of the field. /// The optional cancellation token. /// - Task UpdateOneAsync(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, CancellationToken cancellationToken) + Task UpdateOneAsync( + IClientSessionHandle session, + FilterDefinition filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -331,12 +412,17 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The value of the field. /// The optional partition key. /// - Task UpdateOneAsync(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, string partitionKey) + Task UpdateOneAsync( + IClientSessionHandle session, + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -348,12 +434,18 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The optional partition key. /// The optional cancellation token. /// - Task UpdateOneAsync(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + Task UpdateOneAsync( + IClientSessionHandle session, + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -363,12 +455,16 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The field to update. /// The value of the field. /// A boolean value indicating success. - Task UpdateOneAsync(IClientSessionHandle session, TDocument documentToModify, Expression> field, TField value) + Task UpdateOneAsync( + IClientSessionHandle session, + TDocument documentToModify, + Expression> field, + TField value) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -379,12 +475,17 @@ namespace MongoDbGenericRepository.DataAccess.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) + Task UpdateOneAsync( + IClientSessionHandle session, + TDocument documentToModify, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -396,7 +497,7 @@ namespace MongoDbGenericRepository.DataAccess.Update where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -409,7 +510,7 @@ namespace MongoDbGenericRepository.DataAccess.Update where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -422,7 +523,7 @@ namespace MongoDbGenericRepository.DataAccess.Update where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -431,7 +532,11 @@ 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) + Task UpdateOneAsync( + IClientSessionHandle session, + TDocument documentToModify, + UpdateDefinition update, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; } diff --git a/MongoDbGenericRepository/Abstractions/IBaseReadOnlyRepository.cs b/MongoDbGenericRepository/Abstractions/IBaseReadOnlyRepository.cs index be4bbee..94000b1 100644 --- a/MongoDbGenericRepository/Abstractions/IBaseReadOnlyRepository.cs +++ b/MongoDbGenericRepository/Abstractions/IBaseReadOnlyRepository.cs @@ -2,10 +2,10 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; +using System.Threading; using System.Threading.Tasks; using MongoDB.Driver; using MongoDbGenericRepository.Models; -using CancellationToken = System.Threading.CancellationToken; namespace MongoDbGenericRepository { @@ -488,7 +488,11 @@ namespace MongoDbGenericRepository /// A mongodb counting option. /// An optional partition key. /// An optional cancellation Token. - Task AnyAsync(FilterDefinition condition, CountOptions countOption, string partitionKey, CancellationToken cancellationToken) + Task AnyAsync( + FilterDefinition condition, + CountOptions countOption, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -760,7 +764,11 @@ namespace MongoDbGenericRepository /// A mongodb filter option. /// An optional partition key. /// An optional cancellation Token. - Task> GetAllAsync(FilterDefinition condition, FindOptions findOption, string partitionKey, CancellationToken cancellationToken) + Task> GetAllAsync( + FilterDefinition condition, + FindOptions findOption, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -852,7 +860,11 @@ namespace MongoDbGenericRepository /// A mongodb filter option. /// An optional partition key. /// An optional cancellation Token. - List GetAll(FilterDefinition condition, FindOptions findOption, string partitionKey, CancellationToken cancellationToken) + List GetAll( + FilterDefinition condition, + FindOptions findOption, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1032,7 +1044,11 @@ namespace MongoDbGenericRepository /// A mongodb counting option. /// An optional partitionKey /// An optional cancellation Token. - Task CountAsync(FilterDefinition condition, CountOptions countOption, string partitionKey, CancellationToken cancellationToken) + Task CountAsync( + FilterDefinition condition, + CountOptions countOption, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1241,7 +1257,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by descending. /// An optional cancellation Token. - Task GetByMaxAsync(Expression> filter, Expression> maxValueSelector, CancellationToken cancellationToken) + Task GetByMaxAsync( + Expression> filter, + Expression> maxValueSelector, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1255,7 +1274,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by descending. /// An optional partitionKey. - Task GetByMaxAsync(Expression> filter, Expression> maxValueSelector, string partitionKey) + Task GetByMaxAsync( + Expression> filter, + Expression> maxValueSelector, + string partitionKey) where TDocument : IDocument where TKey : IEquatable; @@ -1269,7 +1291,11 @@ namespace MongoDbGenericRepository /// A property selector to order by descending. /// An optional partitionKey. /// An optional cancellation Token. - Task GetByMaxAsync(Expression> filter, Expression> maxValueSelector, string partitionKey, CancellationToken cancellationToken) + Task GetByMaxAsync( + Expression> filter, + Expression> maxValueSelector, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1294,7 +1320,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by descending. /// An optional cancellation token. - TDocument GetByMax(Expression> filter, Expression> orderByDescending, CancellationToken cancellationToken) + TDocument GetByMax( + Expression> filter, + Expression> orderByDescending, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1307,7 +1336,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by descending. /// An optional partitionKey. - TDocument GetByMax(Expression> filter, Expression> orderByDescending, string partitionKey) + TDocument GetByMax( + Expression> filter, + Expression> orderByDescending, + string partitionKey) where TDocument : IDocument where TKey : IEquatable; @@ -1321,7 +1353,11 @@ namespace MongoDbGenericRepository /// A property selector to order by descending. /// An optional partitionKey. /// An optional cancellation token. - TDocument GetByMax(Expression> filter, Expression> orderByDescending, string partitionKey, CancellationToken cancellationToken) + TDocument GetByMax( + Expression> filter, + Expression> orderByDescending, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1346,7 +1382,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector for the minimum value you are looking for. /// An optional cancellation Token. - Task GetByMinAsync(Expression> filter, Expression> minValueSelector, CancellationToken cancellationToken) + Task GetByMinAsync( + Expression> filter, + Expression> minValueSelector, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1359,7 +1398,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector for the minimum value you are looking for. /// An optional partitionKey. - Task GetByMinAsync(Expression> filter, Expression> minValueSelector, string partitionKey) + Task GetByMinAsync( + Expression> filter, + Expression> minValueSelector, + string partitionKey) where TDocument : IDocument where TKey : IEquatable; @@ -1373,7 +1415,11 @@ namespace MongoDbGenericRepository /// A property selector for the minimum value you are looking for. /// An optional partitionKey. /// An optional cancellation token. - Task GetByMinAsync(Expression> filter, Expression> minValueSelector, string partitionKey, CancellationToken cancellationToken) + Task GetByMinAsync( + Expression> filter, + Expression> minValueSelector, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1398,7 +1444,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector for the minimum value you are looking for. /// An optional cancellation token. - TDocument GetByMin(Expression> filter, Expression> minValueSelector, CancellationToken cancellationToken) + TDocument GetByMin( + Expression> filter, + Expression> minValueSelector, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1425,7 +1474,11 @@ namespace MongoDbGenericRepository /// A property selector for the minimum value you are looking for. /// An optional partitionKey. /// An optional cancellation token. - TDocument GetByMin(Expression> filter, Expression> minValueSelector, string partitionKey, CancellationToken cancellationToken) + TDocument GetByMin( + Expression> filter, + Expression> minValueSelector, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1450,7 +1503,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector for the maximum value you are looking for. /// An optional cancellation Token. - Task GetMaxValueAsync(Expression> filter, Expression> maxValueSelector, CancellationToken cancellationToken) + Task GetMaxValueAsync( + Expression> filter, + Expression> maxValueSelector, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1463,7 +1519,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector for the maximum value you are looking for. /// An optional partitionKey. - Task GetMaxValueAsync(Expression> filter, Expression> maxValueSelector, string partitionKey) + Task GetMaxValueAsync( + Expression> filter, + Expression> maxValueSelector, + string partitionKey) where TDocument : IDocument where TKey : IEquatable; @@ -1477,7 +1536,11 @@ namespace MongoDbGenericRepository /// A property selector for the maximum value you are looking for. /// An optional partitionKey. /// An optional cancellation token. - Task GetMaxValueAsync(Expression> filter, Expression> maxValueSelector, string partitionKey, CancellationToken cancellationToken) + Task GetMaxValueAsync( + Expression> filter, + Expression> maxValueSelector, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1502,7 +1565,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by ascending. /// An optional cancellation token. - TValue GetMaxValue(Expression> filter, Expression> maxValueSelector, CancellationToken cancellationToken) + TValue GetMaxValue( + Expression> filter, + Expression> maxValueSelector, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1515,7 +1581,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by ascending. /// An optional partitionKey. - TValue GetMaxValue(Expression> filter, Expression> maxValueSelector, string partitionKey) + TValue GetMaxValue( + Expression> filter, + Expression> maxValueSelector, + string partitionKey) where TDocument : IDocument where TKey : IEquatable; @@ -1529,7 +1598,11 @@ namespace MongoDbGenericRepository /// A property selector to order by ascending. /// An optional partitionKey. /// An optional cancellation token. - TValue GetMaxValue(Expression> filter, Expression> maxValueSelector, string partitionKey, CancellationToken cancellationToken) + TValue GetMaxValue( + Expression> filter, + Expression> maxValueSelector, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1554,7 +1627,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by ascending. /// An optional cancellation Token. - Task GetMinValueAsync(Expression> filter, Expression> minValueSelector, CancellationToken cancellationToken) + Task GetMinValueAsync( + Expression> filter, + Expression> minValueSelector, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1567,7 +1643,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by ascending. /// An optional partition key. - Task GetMinValueAsync(Expression> filter, Expression> minValueSelector, string partitionKey) + Task GetMinValueAsync( + Expression> filter, + Expression> minValueSelector, + string partitionKey) where TDocument : IDocument where TKey : IEquatable; @@ -1581,7 +1660,11 @@ namespace MongoDbGenericRepository /// A property selector to order by ascending. /// An optional partition key. /// An optional cancellation token. - Task GetMinValueAsync(Expression> filter, Expression> minValueSelector, string partitionKey, CancellationToken cancellationToken) + Task GetMinValueAsync( + Expression> filter, + Expression> minValueSelector, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1606,7 +1689,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by ascending. /// An optional cancellation token. - TValue GetMinValue(Expression> filter, Expression> minValueSelector, CancellationToken cancellationToken) + TValue GetMinValue( + Expression> filter, + Expression> minValueSelector, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1619,7 +1705,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by ascending. /// An optional partition key. - TValue GetMinValue(Expression> filter, Expression> minValueSelector, string partitionKey) + TValue GetMinValue( + Expression> filter, + Expression> minValueSelector, + string partitionKey) where TDocument : IDocument where TKey : IEquatable; @@ -1633,7 +1722,11 @@ namespace MongoDbGenericRepository /// A property selector to order by ascending. /// An optional partition key. /// An optional cancellation token. - TValue GetMinValue(Expression> filter, Expression> minValueSelector, string partitionKey, CancellationToken cancellationToken) + TValue GetMinValue( + Expression> filter, + Expression> minValueSelector, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1660,7 +1753,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// The field you want to sum. /// An optional cancellation Token. - Task SumByAsync(Expression> filter, Expression> selector, CancellationToken cancellationToken) + Task SumByAsync( + Expression> filter, + Expression> selector, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1685,7 +1781,11 @@ namespace MongoDbGenericRepository /// The field you want to sum. /// The partition key of your document, if any. /// An optional cancellation token. - Task SumByAsync(Expression> filter, Expression> selector, string partitionKey, CancellationToken cancellationToken) + Task SumByAsync( + Expression> filter, + Expression> selector, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1720,7 +1820,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// The field you want to sum. /// An optional cancellation token. - Task SumByAsync(Expression> filter, Expression> selector, CancellationToken cancellationToken) + Task SumByAsync( + Expression> filter, + Expression> selector, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1745,7 +1848,11 @@ namespace MongoDbGenericRepository /// The field you want to sum. /// The partition key of your document, if any. /// An optional cancellation token. - Task SumByAsync(Expression> filter, Expression> selector, string partitionKey, CancellationToken cancellationToken) + Task SumByAsync( + Expression> filter, + Expression> selector, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; @@ -1776,7 +1883,9 @@ namespace MongoDbGenericRepository /// The type representing the model you want to project to. /// A LINQ expression filter. /// The projection expression. - Task ProjectOneAsync(Expression> filter, Expression> projection) + Task ProjectOneAsync( + Expression> filter, + Expression> projection) where TDocument : IDocument where TKey : IEquatable where TProjection : class; @@ -1790,7 +1899,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// The projection expression. /// An optional cancellation Token. - Task ProjectOneAsync(Expression> filter, Expression> projection, CancellationToken cancellationToken) + Task ProjectOneAsync( + Expression> filter, + Expression> projection, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable where TProjection : class; @@ -1804,7 +1916,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// The projection expression. /// An optional partition key. - Task ProjectOneAsync(Expression> filter, Expression> projection, string partitionKey) + Task ProjectOneAsync( + Expression> filter, + Expression> projection, + string partitionKey) where TDocument : IDocument where TKey : IEquatable where TProjection : class; @@ -1819,7 +1934,11 @@ namespace MongoDbGenericRepository /// The projection expression. /// An optional partition key. /// An optional cancellation token. - Task ProjectOneAsync(Expression> filter, Expression> projection, string partitionKey, CancellationToken cancellationToken) + Task ProjectOneAsync( + Expression> filter, + Expression> projection, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable where TProjection : class; @@ -1846,7 +1965,10 @@ namespace MongoDbGenericRepository /// /// The projection expression. /// An optional cancellation token. - TProjection ProjectOne(Expression> filter, Expression> projection, CancellationToken cancellationToken) + TProjection ProjectOne( + Expression> filter, + Expression> projection, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable where TProjection : class; @@ -1860,7 +1982,10 @@ namespace MongoDbGenericRepository /// /// The projection expression. /// An optional partition key. - TProjection ProjectOne(Expression> filter, Expression> projection, string partitionKey) + TProjection ProjectOne( + Expression> filter, + Expression> projection, + string partitionKey) where TDocument : IDocument where TKey : IEquatable where TProjection : class; @@ -1875,7 +2000,11 @@ namespace MongoDbGenericRepository /// The projection expression. /// An optional partition key. /// An optional cancellation token. - TProjection ProjectOne(Expression> filter, Expression> projection, string partitionKey, CancellationToken cancellationToken) + TProjection ProjectOne( + Expression> filter, + Expression> projection, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable where TProjection : class; @@ -1888,7 +2017,9 @@ namespace MongoDbGenericRepository /// The type representing the model you want to project to. /// A LINQ expression filter. /// The projection expression. - Task> ProjectManyAsync(Expression> filter, Expression> projection) + Task> ProjectManyAsync( + Expression> filter, + Expression> projection) where TDocument : IDocument where TKey : IEquatable where TProjection : class; @@ -1902,7 +2033,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// The projection expression. /// An optional cancellation Token. - Task> ProjectManyAsync(Expression> filter, Expression> projection, CancellationToken cancellationToken) + Task> ProjectManyAsync( + Expression> filter, + Expression> projection, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable where TProjection : class; @@ -1916,7 +2050,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// The projection expression. /// An optional partition key. - Task> ProjectManyAsync(Expression> filter, Expression> projection, string partitionKey) + Task> ProjectManyAsync( + Expression> filter, + Expression> projection, + string partitionKey) where TDocument : IDocument where TKey : IEquatable where TProjection : class; @@ -1931,7 +2068,11 @@ namespace MongoDbGenericRepository /// The projection expression. /// An optional partition key. /// An optional cancellation token. - Task> ProjectManyAsync(Expression> filter, Expression> projection, string partitionKey, CancellationToken cancellationToken) + Task> ProjectManyAsync( + Expression> filter, + Expression> projection, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable where TProjection : class; @@ -1944,7 +2085,9 @@ namespace MongoDbGenericRepository /// The type representing the model you want to project to. /// /// The projection expression. - List ProjectMany(Expression> filter, Expression> projection) + List ProjectMany( + Expression> filter, + Expression> projection) where TDocument : IDocument where TKey : IEquatable where TProjection : class; @@ -1958,7 +2101,10 @@ namespace MongoDbGenericRepository /// /// The projection expression. /// An optional cancellation token. - List ProjectMany(Expression> filter, Expression> projection, CancellationToken cancellationToken) + List ProjectMany( + Expression> filter, + Expression> projection, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable where TProjection : class; @@ -1972,7 +2118,10 @@ namespace MongoDbGenericRepository /// /// The projection expression. /// An optional partition key. - List ProjectMany(Expression> filter, Expression> projection, string partitionKey) + List ProjectMany( + Expression> filter, + Expression> projection, + string partitionKey) where TDocument : IDocument where TKey : IEquatable where TProjection : class; @@ -1987,7 +2136,11 @@ namespace MongoDbGenericRepository /// The projection expression. /// An optional partition key. /// An optional cancellation token. - List ProjectMany(Expression> filter, Expression> projection, string partitionKey, CancellationToken cancellationToken) + List ProjectMany( + Expression> filter, + Expression> projection, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable where TProjection : class; @@ -2006,7 +2159,9 @@ namespace MongoDbGenericRepository /// The type of the primary key. /// The grouping criteria. /// The projected group result. - List GroupBy(Expression> groupingCriteria, Expression, TProjection>> groupProjection) + List GroupBy( + Expression> groupingCriteria, + Expression, TProjection>> groupProjection) where TDocument : IDocument where TKey : IEquatable where TProjection : class, new(); @@ -2022,7 +2177,10 @@ namespace MongoDbGenericRepository /// The grouping criteria. /// The projected group result. /// An optional cancellation token. - List GroupBy(Expression> groupingCriteria, Expression, TProjection>> groupProjection, CancellationToken cancellationToken) + List GroupBy( + Expression> groupingCriteria, + Expression, TProjection>> groupProjection, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable where TProjection : class, new(); @@ -2038,7 +2196,10 @@ namespace MongoDbGenericRepository /// The grouping criteria. /// The projected group result. /// The partition key of your document, if any. - List GroupBy(Expression> groupingCriteria, Expression, TProjection>> groupProjection, string partitionKey) + List GroupBy( + Expression> groupingCriteria, + Expression, TProjection>> groupProjection, + string partitionKey) where TDocument : IDocument where TKey : IEquatable where TProjection : class, new(); @@ -2055,7 +2216,11 @@ namespace MongoDbGenericRepository /// The projected group result. /// The partition key of your document, if any. /// An optional cancellation token. - List GroupBy(Expression> groupingCriteria, Expression, TProjection>> groupProjection, string partitionKey, CancellationToken cancellationToken) + List GroupBy( + Expression> groupingCriteria, + Expression, TProjection>> groupProjection, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable where TProjection : class, new(); @@ -2071,7 +2236,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// The grouping criteria. /// The projected group result. - List GroupBy(Expression> filter, Expression> groupingCriteria, Expression, TProjection>> groupProjection) + List GroupBy( + Expression> filter, + Expression> groupingCriteria, + Expression, TProjection>> groupProjection) where TDocument : IDocument where TKey : IEquatable where TProjection : class, new(); @@ -2088,7 +2256,11 @@ namespace MongoDbGenericRepository /// The grouping criteria. /// The projected group result. /// An optional cancellation token. - List GroupBy(Expression> filter, Expression> groupingCriteria, Expression, TProjection>> groupProjection, CancellationToken cancellationToken) + List GroupBy( + Expression> filter, + Expression> groupingCriteria, + Expression, TProjection>> groupProjection, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable where TProjection : class, new(); @@ -2105,7 +2277,11 @@ namespace MongoDbGenericRepository /// The grouping criteria. /// The projected group result. /// The partition key of your document, if any. - List GroupBy(Expression> filter, Expression> groupingCriteria, Expression, TProjection>> groupProjection, string partitionKey) + List GroupBy( + Expression> filter, + Expression> groupingCriteria, + Expression, TProjection>> groupProjection, + string partitionKey) where TDocument : IDocument where TKey : IEquatable where TProjection : class, new(); @@ -2123,7 +2299,12 @@ namespace MongoDbGenericRepository /// The projected group result. /// The partition key of your document, if any. /// An optional cancellation token. - List GroupBy(Expression> filter, Expression> groupingCriteria, Expression, TProjection>> groupProjection, string partitionKey, CancellationToken cancellationToken) + List GroupBy( + Expression> filter, + Expression> groupingCriteria, + Expression, TProjection>> groupProjection, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable where TProjection : class, new(); diff --git a/MongoDbGenericRepository/Abstractions/IReadOnlyMongoRepository.TKey.cs b/MongoDbGenericRepository/Abstractions/IReadOnlyMongoRepository.TKey.cs index d7d2124..d518853 100644 --- a/MongoDbGenericRepository/Abstractions/IReadOnlyMongoRepository.TKey.cs +++ b/MongoDbGenericRepository/Abstractions/IReadOnlyMongoRepository.TKey.cs @@ -410,7 +410,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by descending. /// The cancellation token. - Task GetByMaxAsync(Expression> filter, Expression> orderByDescending, CancellationToken cancellationToken) + Task GetByMaxAsync( + Expression> filter, + Expression> orderByDescending, + CancellationToken cancellationToken) where TDocument : IDocument; /// @@ -421,7 +424,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by descending. /// An optional partitionKey. - Task GetByMaxAsync(Expression> filter, Expression> orderByDescending, string partitionKey) + Task GetByMaxAsync( + Expression> filter, + Expression> orderByDescending, + string partitionKey) where TDocument : IDocument; /// @@ -433,7 +439,11 @@ namespace MongoDbGenericRepository /// A property selector to order by descending. /// An optional partitionKey. /// The cancellation token. - Task GetByMaxAsync(Expression> filter, Expression> orderByDescending, string partitionKey, CancellationToken cancellationToken) + Task GetByMaxAsync( + Expression> filter, + Expression> orderByDescending, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument; /// @@ -456,7 +466,10 @@ namespace MongoDbGenericRepository /// A property selector to order by descending. /// The cancellation token. /// - TDocument GetByMax(Expression> filter, Expression> orderByDescending, CancellationToken cancellationToken) + TDocument GetByMax( + Expression> filter, + Expression> orderByDescending, + CancellationToken cancellationToken) where TDocument : IDocument; /// @@ -481,7 +494,11 @@ namespace MongoDbGenericRepository /// An optional partitionKey. /// The cancellation token. /// - TDocument GetByMax(Expression> filter, Expression> orderByDescending, string partitionKey, CancellationToken cancellationToken) + TDocument GetByMax( + Expression> filter, + Expression> orderByDescending, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument; /// @@ -502,7 +519,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by ascending. /// The cancellation token. - Task GetByMinAsync(Expression> filter, Expression> orderByAscending, CancellationToken cancellationToken) + Task GetByMinAsync( + Expression> filter, + Expression> orderByAscending, + CancellationToken cancellationToken) where TDocument : IDocument; /// @@ -513,7 +533,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by ascending. /// An optional partitionKey. - Task GetByMinAsync(Expression> filter, Expression> orderByAscending, string partitionKey) + Task GetByMinAsync( + Expression> filter, + Expression> orderByAscending, + string partitionKey) where TDocument : IDocument; /// @@ -525,7 +548,11 @@ namespace MongoDbGenericRepository /// A property selector to order by ascending. /// An optional partitionKey. /// The cancellation token. - Task GetByMinAsync(Expression> filter, Expression> orderByAscending, string partitionKey, CancellationToken cancellationToken) + Task GetByMinAsync( + Expression> filter, + Expression> orderByAscending, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument; /// @@ -546,7 +573,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by ascending. /// The cancellation token. - TDocument GetByMin(Expression> filter, Expression> orderByAscending, CancellationToken cancellationToken) + TDocument GetByMin( + Expression> filter, + Expression> orderByAscending, + CancellationToken cancellationToken) where TDocument : IDocument; /// @@ -569,7 +599,11 @@ namespace MongoDbGenericRepository /// A property selector to order by ascending. /// An optional partitionKey. /// The cancellation token. - TDocument GetByMin(Expression> filter, Expression> orderByAscending, string partitionKey, CancellationToken cancellationToken) + TDocument GetByMin( + Expression> filter, + Expression> orderByAscending, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument; /// @@ -590,7 +624,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by ascending. /// The cancellation token. - Task GetMaxValueAsync(Expression> filter, Expression> maxValueSelector, CancellationToken cancellationToken) + Task GetMaxValueAsync( + Expression> filter, + Expression> maxValueSelector, + CancellationToken cancellationToken) where TDocument : IDocument; /// @@ -601,7 +638,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by ascending. /// An optional partitionKey. - Task GetMaxValueAsync(Expression> filter, Expression> maxValueSelector, string partitionKey) + Task GetMaxValueAsync( + Expression> filter, + Expression> maxValueSelector, + string partitionKey) where TDocument : IDocument; /// @@ -613,7 +653,11 @@ namespace MongoDbGenericRepository /// A property selector to order by ascending. /// An optional partitionKey. /// The cancellation token. - Task GetMaxValueAsync(Expression> filter, Expression> maxValueSelector, string partitionKey, CancellationToken cancellationToken) + Task GetMaxValueAsync( + Expression> filter, + Expression> maxValueSelector, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument; /// @@ -634,7 +678,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by ascending. /// The cancellation token. - TValue GetMaxValue(Expression> filter, Expression> maxValueSelector, CancellationToken cancellationToken) + TValue GetMaxValue( + Expression> filter, + Expression> maxValueSelector, + CancellationToken cancellationToken) where TDocument : IDocument; @@ -646,7 +693,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by ascending. /// An optional partitionKey. - TValue GetMaxValue(Expression> filter, Expression> maxValueSelector, string partitionKey) + TValue GetMaxValue( + Expression> filter, + Expression> maxValueSelector, + string partitionKey) where TDocument : IDocument; /// @@ -658,7 +708,11 @@ namespace MongoDbGenericRepository /// A property selector to order by ascending. /// An optional partitionKey. /// The cancellation token. - TValue GetMaxValue(Expression> filter, Expression> maxValueSelector, string partitionKey, CancellationToken cancellationToken) + TValue GetMaxValue( + Expression> filter, + Expression> maxValueSelector, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument; /// @@ -680,7 +734,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by ascending. /// The cancellation token. - Task GetMinValueAsync(Expression> filter, Expression> minValueSelector, CancellationToken cancellationToken) + Task GetMinValueAsync( + Expression> filter, + Expression> minValueSelector, + CancellationToken cancellationToken) where TDocument : IDocument; @@ -692,7 +749,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by ascending. /// An optional partition key. - Task GetMinValueAsync(Expression> filter, Expression> minValueSelector, string partitionKey) + Task GetMinValueAsync( + Expression> filter, + Expression> minValueSelector, + string partitionKey) where TDocument : IDocument; /// @@ -704,7 +764,11 @@ namespace MongoDbGenericRepository /// A property selector to order by ascending. /// An optional partition key. /// The cancellation token. - Task GetMinValueAsync(Expression> filter, Expression> minValueSelector, string partitionKey, CancellationToken cancellationToken) + Task GetMinValueAsync( + Expression> filter, + Expression> minValueSelector, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument; /// @@ -725,7 +789,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by ascending. /// The cancellation token. - TValue GetMinValue(Expression> filter, Expression> minValueSelector, CancellationToken cancellationToken) + TValue GetMinValue( + Expression> filter, + Expression> minValueSelector, + CancellationToken cancellationToken) where TDocument : IDocument; @@ -737,7 +804,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// A property selector to order by ascending. /// An optional partition key. - TValue GetMinValue(Expression> filter, Expression> minValueSelector, string partitionKey) + TValue GetMinValue( + Expression> filter, + Expression> minValueSelector, + string partitionKey) where TDocument : IDocument; /// @@ -749,7 +819,11 @@ namespace MongoDbGenericRepository /// A property selector to order by ascending. /// An optional partition key. /// The cancellation token. - TValue GetMinValue(Expression> filter, Expression> minValueSelector, string partitionKey, CancellationToken cancellationToken) + TValue GetMinValue( + Expression> filter, + Expression> minValueSelector, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument; #endregion @@ -772,7 +846,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// The field you want to sum. /// The cancellation token. - Task SumByAsync(Expression> filter, Expression> selector, CancellationToken cancellationToken) + Task SumByAsync( + Expression> filter, + Expression> selector, + CancellationToken cancellationToken) where TDocument : IDocument; /// @@ -793,7 +870,11 @@ namespace MongoDbGenericRepository /// The field you want to sum. /// The partition key of your document, if any. /// The cancellation token. - Task SumByAsync(Expression> filter, Expression> selector, string partitionKey, CancellationToken cancellationToken) + Task SumByAsync( + Expression> filter, + Expression> selector, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument; /// @@ -812,7 +893,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// The field you want to sum. /// The cancellation token. - Task SumByAsync(Expression> filter, Expression> selector, CancellationToken cancellationToken) + Task SumByAsync( + Expression> filter, + Expression> selector, + CancellationToken cancellationToken) where TDocument : IDocument; /// @@ -833,7 +917,11 @@ namespace MongoDbGenericRepository /// The field you want to sum. /// The partition key of your document, if any. /// The cancellation token. - Task SumByAsync(Expression> filter, Expression> selector, string partitionKey, CancellationToken cancellationToken) + Task SumByAsync( + Expression> filter, + Expression> selector, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument; /// @@ -885,7 +973,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// The projection expression. /// The cancellation token - Task ProjectOneAsync(Expression> filter, Expression> projection, CancellationToken cancellationToken) + Task ProjectOneAsync( + Expression> filter, + Expression> projection, + CancellationToken cancellationToken) where TDocument : IDocument where TProjection : class; @@ -897,7 +988,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// The projection expression. /// An optional partition key. - Task ProjectOneAsync(Expression> filter, Expression> projection, string partitionKey) + Task ProjectOneAsync( + Expression> filter, + Expression> projection, + string partitionKey) where TDocument : IDocument where TProjection : class; @@ -910,9 +1004,14 @@ namespace MongoDbGenericRepository /// The projection expression. /// An optional partition key. /// The cancellation token - Task ProjectOneAsync(Expression> filter, Expression> projection, string partitionKey, CancellationToken cancellationToken) + Task ProjectOneAsync( + Expression> filter, + Expression> projection, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TProjection : class; + /// /// Returns a projected document matching the filter condition. /// @@ -932,7 +1031,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// The projection expression. /// The cancellation token. - TProjection ProjectOne(Expression> filter, Expression> projection, CancellationToken cancellationToken) + TProjection ProjectOne( + Expression> filter, + Expression> projection, + CancellationToken cancellationToken) where TDocument : IDocument where TProjection : class; @@ -944,7 +1046,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// The projection expression. /// An optional partition key. - TProjection ProjectOne(Expression> filter, Expression> projection, string partitionKey) + TProjection ProjectOne( + Expression> filter, + Expression> projection, + string partitionKey) where TDocument : IDocument where TProjection : class; @@ -957,7 +1062,11 @@ namespace MongoDbGenericRepository /// The projection expression. /// An optional partition key. /// The cancellation token. - TProjection ProjectOne(Expression> filter, Expression> projection, string partitionKey, CancellationToken cancellationToken) + TProjection ProjectOne( + Expression> filter, + Expression> projection, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TProjection : class; @@ -968,7 +1077,9 @@ namespace MongoDbGenericRepository /// The type representing the model you want to project to. /// A LINQ expression filter. /// The projection expression. - Task> ProjectManyAsync(Expression> filter, Expression> projection) + Task> ProjectManyAsync( + Expression> filter, + Expression> projection) where TDocument : IDocument where TProjection : class; @@ -980,7 +1091,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// The projection expression. /// The cancellation token. - Task> ProjectManyAsync(Expression> filter, Expression> projection, CancellationToken cancellationToken) + Task> ProjectManyAsync( + Expression> filter, + Expression> projection, + CancellationToken cancellationToken) where TDocument : IDocument where TProjection : class; @@ -992,7 +1106,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// The projection expression. /// An optional partition key. - Task> ProjectManyAsync(Expression> filter, Expression> projection, string partitionKey) + Task> ProjectManyAsync( + Expression> filter, + Expression> projection, + string partitionKey) where TDocument : IDocument where TProjection : class; @@ -1005,7 +1122,11 @@ namespace MongoDbGenericRepository /// The projection expression. /// An optional partition key. /// The cancellation token. - Task> ProjectManyAsync(Expression> filter, Expression> projection, string partitionKey, CancellationToken cancellationToken) + Task> ProjectManyAsync( + Expression> filter, + Expression> projection, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TProjection : class; @@ -1028,7 +1149,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// The projection expression. /// The cancellation token - List ProjectMany(Expression> filter, Expression> projection, CancellationToken cancellationToken) + List ProjectMany( + Expression> filter, + Expression> projection, + CancellationToken cancellationToken) where TDocument : IDocument where TProjection : class; @@ -1040,7 +1164,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// The projection expression. /// An optional partition key. - List ProjectMany(Expression> filter, Expression> projection, string partitionKey) + List ProjectMany( + Expression> filter, + Expression> projection, + string partitionKey) where TDocument : IDocument where TProjection : class; @@ -1053,7 +1180,11 @@ namespace MongoDbGenericRepository /// The projection expression. /// An optional partition key. /// The cancellation token - List ProjectMany(Expression> filter, Expression> projection, string partitionKey, CancellationToken cancellationToken) + List ProjectMany( + Expression> filter, + Expression> projection, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TProjection : class; @@ -1070,7 +1201,9 @@ namespace MongoDbGenericRepository /// The type of the projected group. /// The grouping criteria. /// The projected group result. - List GroupBy(Expression> groupingCriteria, Expression, TProjection>> groupProjection) + List GroupBy( + Expression> groupingCriteria, + Expression, TProjection>> groupProjection) where TDocument : IDocument where TProjection : class, new(); @@ -1084,7 +1217,10 @@ namespace MongoDbGenericRepository /// The grouping criteria. /// The projected group result. /// The cancellation token. - List GroupBy(Expression> groupingCriteria, Expression, TProjection>> groupProjection, CancellationToken cancellationToken) + List GroupBy( + Expression> groupingCriteria, + Expression, TProjection>> groupProjection, + CancellationToken cancellationToken) where TDocument : IDocument where TProjection : class, new(); @@ -1098,7 +1234,10 @@ namespace MongoDbGenericRepository /// The grouping criteria. /// The projected group result. /// The partition key of your document, if any. - List GroupBy(Expression> groupingCriteria, Expression, TProjection>> groupProjection, string partitionKey) + List GroupBy( + Expression> groupingCriteria, + Expression, TProjection>> groupProjection, + string partitionKey) where TDocument : IDocument where TProjection : class, new(); @@ -1113,7 +1252,11 @@ namespace MongoDbGenericRepository /// The projected group result. /// The partition key of your document, if any. /// The cancellation token. - List GroupBy(Expression> groupingCriteria, Expression, TProjection>> groupProjection, string partitionKey, CancellationToken cancellationToken) + List GroupBy( + Expression> groupingCriteria, + Expression, TProjection>> groupProjection, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TProjection : class, new(); @@ -1127,7 +1270,10 @@ namespace MongoDbGenericRepository /// A LINQ expression filter. /// The grouping criteria. /// The projected group result. - List GroupBy(Expression> filter, Expression> groupingCriteria, Expression, TProjection>> groupProjection) + List GroupBy( + Expression> filter, + Expression> groupingCriteria, + Expression, TProjection>> groupProjection) where TDocument : IDocument where TProjection : class, new(); @@ -1142,7 +1288,11 @@ namespace MongoDbGenericRepository /// The grouping criteria. /// The projected group result. /// The cancellation token. - List GroupBy(Expression> filter, Expression> groupingCriteria, Expression, TProjection>> groupProjection, CancellationToken cancellationToken) + List GroupBy( + Expression> filter, + Expression> groupingCriteria, + Expression, TProjection>> groupProjection, + CancellationToken cancellationToken) where TDocument : IDocument where TProjection : class, new(); @@ -1157,7 +1307,11 @@ namespace MongoDbGenericRepository /// The grouping criteria. /// The projected group result. /// The partition key of your document, if any. - List GroupBy(Expression> filter, Expression> groupingCriteria, Expression, TProjection>> groupProjection, string partitionKey) + List GroupBy( + Expression> filter, + Expression> groupingCriteria, + Expression, TProjection>> groupProjection, + string partitionKey) where TDocument : IDocument where TProjection : class, new(); @@ -1173,7 +1327,12 @@ namespace MongoDbGenericRepository /// The projected group result. /// The partition key of your document, if any. /// The cancellation token. - List GroupBy(Expression> filter, Expression> groupingCriteria, Expression, TProjection>> groupProjection, string partitionKey, CancellationToken cancellationToken) + List GroupBy( + Expression> filter, + Expression> groupingCriteria, + Expression, TProjection>> groupProjection, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TProjection : class, new(); diff --git a/MongoDbGenericRepository/Abstractions/IReadOnlyMongoRepository.cs b/MongoDbGenericRepository/Abstractions/IReadOnlyMongoRepository.cs index 1dad5fb..0585cc3 100644 --- a/MongoDbGenericRepository/Abstractions/IReadOnlyMongoRepository.cs +++ b/MongoDbGenericRepository/Abstractions/IReadOnlyMongoRepository.cs @@ -7,6 +7,5 @@ namespace MongoDbGenericRepository /// public interface IReadOnlyMongoRepository : IBaseReadOnlyRepository, IReadOnlyMongoRepository { - } -} +} \ No newline at end of file diff --git a/MongoDbGenericRepository/BaseMongoRepository.Index.cs b/MongoDbGenericRepository/BaseMongoRepository.Index.cs index 9ed7e9d..b56b60f 100644 --- a/MongoDbGenericRepository/BaseMongoRepository.Index.cs +++ b/MongoDbGenericRepository/BaseMongoRepository.Index.cs @@ -422,7 +422,10 @@ namespace MongoDbGenericRepository } /// - public async Task CreateDescendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken) + public async Task CreateDescendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + CancellationToken cancellationToken) where TDocument : IDocument { return await CreateDescendingIndexAsync(field, indexCreationOptions, null, cancellationToken); @@ -436,21 +439,31 @@ namespace MongoDbGenericRepository } /// - public async Task CreateDescendingIndexAsync(Expression> field, string partitionKey, CancellationToken cancellationToken) + public async Task CreateDescendingIndexAsync( + Expression> field, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await CreateDescendingIndexAsync(field, null, partitionKey, cancellationToken); } /// - public async Task CreateDescendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey) + public async Task CreateDescendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey) where TDocument : IDocument { return await CreateDescendingIndexAsync(field, indexCreationOptions, partitionKey, CancellationToken.None); } /// - public async Task CreateDescendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken) + public async Task CreateDescendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await CreateDescendingIndexAsync(field, indexCreationOptions, partitionKey, cancellationToken); @@ -465,7 +478,9 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateDescendingIndexAsync(Expression> field, CancellationToken cancellationToken) + public virtual async Task CreateDescendingIndexAsync( + Expression> field, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -473,7 +488,9 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateDescendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions) + public virtual async Task CreateDescendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions) where TDocument : IDocument where TKey : IEquatable { @@ -482,7 +499,10 @@ namespace MongoDbGenericRepository /// - public virtual async Task CreateDescendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken) + public virtual async Task CreateDescendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -498,7 +518,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateDescendingIndexAsync(Expression> field, string partitionKey, CancellationToken cancellationToken) + public virtual async Task CreateDescendingIndexAsync( + Expression> field, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -506,7 +529,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateDescendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey) + public virtual async Task CreateDescendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey) where TDocument : IDocument where TKey : IEquatable { @@ -514,7 +540,11 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateDescendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken) + public virtual async Task CreateDescendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -543,7 +573,10 @@ namespace MongoDbGenericRepository } /// - public async Task CreateHashedIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken) + public async Task CreateHashedIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + CancellationToken cancellationToken) where TDocument : IDocument { return await CreateHashedIndexAsync(field, indexCreationOptions, null, cancellationToken); @@ -557,21 +590,31 @@ namespace MongoDbGenericRepository } /// - public async Task CreateHashedIndexAsync(Expression> field, string partitionKey, CancellationToken cancellationToken) + public async Task CreateHashedIndexAsync( + Expression> field, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await CreateHashedIndexAsync(field, null, partitionKey, cancellationToken); } /// - public async Task CreateHashedIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey) + public async Task CreateHashedIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey) where TDocument : IDocument { return await CreateHashedIndexAsync(field, indexCreationOptions, partitionKey, CancellationToken.None); } /// - public async Task CreateHashedIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken) + public async Task CreateHashedIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await CreateHashedIndexAsync(field, indexCreationOptions, partitionKey, cancellationToken); @@ -586,7 +629,9 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateHashedIndexAsync(Expression> field, CancellationToken cancellationToken) + public virtual async Task CreateHashedIndexAsync( + Expression> field, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -594,7 +639,9 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateHashedIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions) + public virtual async Task CreateHashedIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions) where TDocument : IDocument where TKey : IEquatable { @@ -602,7 +649,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateHashedIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken) + public virtual async Task CreateHashedIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -618,7 +668,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateHashedIndexAsync(Expression> field, string partitionKey, CancellationToken cancellationToken) + public virtual async Task CreateHashedIndexAsync( + Expression> field, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -626,7 +679,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateHashedIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey) + public virtual async Task CreateHashedIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey) where TDocument : IDocument where TKey : IEquatable { @@ -634,7 +690,11 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateHashedIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken) + public virtual async Task CreateHashedIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -649,21 +709,28 @@ namespace MongoDbGenericRepository } /// - public async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, CancellationToken cancellationToken) + public async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + CancellationToken cancellationToken) where TDocument : IDocument { return await CreateCombinedTextIndexAsync(fields, null, null, cancellationToken); } /// - public async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions) + public async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions) where TDocument : IDocument { return await CreateCombinedTextIndexAsync(fields, indexCreationOptions, null, CancellationToken.None); } /// - public async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken) + public async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions, + CancellationToken cancellationToken) where TDocument : IDocument { return await CreateCombinedTextIndexAsync(fields, indexCreationOptions, null, cancellationToken); @@ -677,21 +744,31 @@ namespace MongoDbGenericRepository } /// - public async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, string partitionKey, CancellationToken cancellationToken) + public async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await CreateCombinedTextIndexAsync(fields, null, partitionKey, cancellationToken); } /// - public async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions, string partitionKey) + public async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions, + string partitionKey) where TDocument : IDocument { return await CreateCombinedTextIndexAsync(fields, indexCreationOptions, partitionKey, CancellationToken.None); } /// - public async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken) + public async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await CreateCombinedTextIndexAsync(fields, indexCreationOptions, partitionKey, cancellationToken); @@ -706,7 +783,9 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, CancellationToken cancellationToken) + public virtual async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -714,7 +793,9 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions) + public virtual async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions) where TDocument : IDocument where TKey : IEquatable { @@ -722,7 +803,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken) + public virtual async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -730,7 +814,9 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, string partitionKey) + public virtual async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + string partitionKey) where TDocument : IDocument where TKey : IEquatable { @@ -738,7 +824,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, string partitionKey, CancellationToken cancellationToken) + public virtual async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -746,7 +835,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions, string partitionKey) + public virtual async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions, + string partitionKey) where TDocument : IDocument where TKey : IEquatable { @@ -754,7 +846,11 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken) + public virtual async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { diff --git a/MongoDbGenericRepository/BaseMongoRepository.Main.cs b/MongoDbGenericRepository/BaseMongoRepository.Main.cs index f86f9c7..fdbf67f 100644 --- a/MongoDbGenericRepository/BaseMongoRepository.Main.cs +++ b/MongoDbGenericRepository/BaseMongoRepository.Main.cs @@ -1,21 +1,21 @@ -using MongoDB.Driver; -using MongoDbGenericRepository.Models; -using MongoDbGenericRepository.Utils; -using System; +using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Threading.Tasks; +using MongoDB.Driver; +using MongoDbGenericRepository.Models; +using MongoDbGenericRepository.Utils; namespace MongoDbGenericRepository { /// - /// The base Repository, it is meant to be inherited from by your custom custom MongoRepository implementation. - /// Its constructor must be given a connection string and a database name. + /// The base Repository, it is meant to be inherited from by your custom custom MongoRepository implementation. + /// Its constructor must be given a connection string and a database name. /// public abstract partial class BaseMongoRepository : ReadOnlyMongoRepository, IBaseMongoRepository { /// - /// The constructor taking a connection string and a database name. + /// The constructor taking a connection string and a database name. /// /// The connection string of the MongoDb server. /// The name of the database against which you want to perform operations. @@ -24,23 +24,23 @@ namespace MongoDbGenericRepository } /// - /// The constructor taking a . + /// The constructor taking a . /// - /// A mongodb context implementing + /// A mongodb context implementing protected BaseMongoRepository(IMongoDbContext mongoDbContext) : base(mongoDbContext) { } /// - /// The constructor taking a . + /// The constructor taking a . /// - /// A mongodb context implementing + /// A mongodb context implementing protected BaseMongoRepository(IMongoDatabase mongoDatabase) : base(mongoDatabase) { } /// - /// Asynchronously returns a paginated list of the documents matching the filter condition. + /// Asynchronously returns a paginated list of the documents matching the filter condition. /// /// The type representing a Document. /// A LINQ expression filter. @@ -58,7 +58,7 @@ namespace MongoDbGenericRepository } /// - /// Asynchronously returns a paginated list of the documents matching the filter condition. + /// Asynchronously returns a paginated list of the documents matching the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -66,48 +66,19 @@ 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. - public virtual async Task> GetPaginatedAsync(Expression> filter, int skipNumber = 0, int takeNumber = 50, string partitionKey = null) + public virtual async Task> GetPaginatedAsync( + Expression> filter, + int skipNumber = 0, + int takeNumber = 50, + string partitionKey = null) where TDocument : IDocument where TKey : IEquatable { return await HandlePartitioned(partitionKey).Find(filter).Skip(skipNumber).Limit(takeNumber).ToListAsync(); } - #region Find And Update - /// - /// GetAndUpdateOne with filter - /// - /// The type representing a Document. - /// A LINQ expression filter. - /// - /// - /// - public virtual async Task GetAndUpdateOne(FilterDefinition filter, UpdateDefinition update, FindOneAndUpdateOptions options) where TDocument : IDocument - { - return await GetCollection().FindOneAndUpdateAsync(filter, update, options); - } - - /// - /// GetAndUpdateOne with filter - /// - /// The type representing a Document. - /// The type of the primary key for a Document. - /// A LINQ expression filter. - /// - /// - /// - public virtual async Task GetAndUpdateOne(FilterDefinition filter, UpdateDefinition update, FindOneAndUpdateOptions options) - where TDocument : IDocument - where TKey : IEquatable - { - return await GetCollection().FindOneAndUpdateAsync(filter, update, options); - } - - #endregion Find And Update - - /// - /// Sets the value of the document Id if it is not set already. + /// Sets the value of the document Id if it is not set already. /// /// The document type. /// The type of the primary key. @@ -120,6 +91,7 @@ namespace MongoDbGenericRepository { throw new ArgumentNullException(nameof(document)); } + var defaultTKey = default(TKey); if (document.Id == null || (defaultTKey != null @@ -130,24 +102,26 @@ namespace MongoDbGenericRepository } /// - /// Sets the value of the document Id if it is not set already. + /// Sets the value of the document Id if it is not set already. /// /// The document type. /// The document. - protected void FormatDocument(TDocument document) where TDocument : IDocument + protected void FormatDocument(TDocument document) + where TDocument : IDocument { if (document == null) { throw new ArgumentNullException(nameof(document)); } - if (document.Id == default(Guid)) + + if (document.Id == default) { document.Id = Guid.NewGuid(); } } /// - /// Gets a collections for a potentially partitioned document type. + /// Gets a collections for a potentially partitioned document type. /// /// The document type. /// The collection partition key. @@ -159,11 +133,12 @@ namespace MongoDbGenericRepository { return GetCollection(partitionKey); } + return GetCollection(); } /// - /// Gets a collections for the type TDocument with a partition key. + /// Gets a collections for the type TDocument with a partition key. /// /// The document type. /// The collection partition key. @@ -173,5 +148,45 @@ namespace MongoDbGenericRepository { return MongoDbContext.GetCollection(partitionKey); } + + #region Find And Update + + /// + /// GetAndUpdateOne with filter + /// + /// The type representing a Document. + /// A LINQ expression filter. + /// + /// + /// + public virtual async Task GetAndUpdateOne( + FilterDefinition filter, + UpdateDefinition update, + FindOneAndUpdateOptions options) + where TDocument : IDocument + { + return await GetCollection().FindOneAndUpdateAsync(filter, update, options); + } + + /// + /// GetAndUpdateOne with filter + /// + /// The type representing a Document. + /// The type of the primary key for a Document. + /// A LINQ expression filter. + /// + /// + /// + public virtual async Task GetAndUpdateOne( + FilterDefinition filter, + UpdateDefinition update, + FindOneAndUpdateOptions options) + where TDocument : IDocument + where TKey : IEquatable + { + return await GetCollection().FindOneAndUpdateAsync(filter, update, options); + } + + #endregion Find And Update } } \ No newline at end of file diff --git a/MongoDbGenericRepository/BaseMongoRepository.Update.cs b/MongoDbGenericRepository/BaseMongoRepository.Update.cs index 3d4ccb7..9b22fd7 100644 --- a/MongoDbGenericRepository/BaseMongoRepository.Update.cs +++ b/MongoDbGenericRepository/BaseMongoRepository.Update.cs @@ -1,29 +1,32 @@ -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 { /// - /// The base Repository, it is meant to be inherited from by your custom custom MongoRepository implementation. - /// Its constructor must be given a connection string and a database name. + /// The base Repository, it is meant to be inherited from by your custom custom MongoRepository implementation. + /// Its constructor must be given a connection string and a database name. /// public abstract partial class BaseMongoRepository : IBaseMongoRepository_Update { private IMongoDbUpdater _mongoDbUpdater; /// - /// The MongoDb accessor to update data. + /// The MongoDb accessor to update data. /// protected virtual IMongoDbUpdater MongoDbUpdater { get { - if (_mongoDbUpdater != null) { return _mongoDbUpdater; } + if (_mongoDbUpdater != null) + { + return _mongoDbUpdater; + } lock (_initLock) { @@ -35,7 +38,7 @@ namespace MongoDbGenericRepository return _mongoDbUpdater; } - set { _mongoDbUpdater = value; } + set => _mongoDbUpdater = value; } #region Update @@ -76,7 +79,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateOneAsync(TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken) + public virtual async Task UpdateOneAsync( + TDocument documentToModify, + UpdateDefinition update, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbUpdater.UpdateOneAsync(documentToModify, update, cancellationToken); @@ -104,7 +110,11 @@ namespace MongoDbGenericRepository } /// - public virtual bool UpdateOne(TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken) + public virtual bool UpdateOne( + TDocument documentToModify, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return MongoDbUpdater.UpdateOne(documentToModify, field, value, cancellationToken); @@ -116,8 +126,13 @@ namespace MongoDbGenericRepository { return await UpdateOneAsync(documentToModify, field, value, CancellationToken.None); } + /// - public virtual async Task UpdateOneAsync(TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken) + public virtual async Task UpdateOneAsync( + TDocument documentToModify, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbUpdater.UpdateOneAsync(documentToModify, field, value, cancellationToken); @@ -131,21 +146,34 @@ namespace MongoDbGenericRepository } /// - public virtual bool UpdateOne(FilterDefinition filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual bool UpdateOne( + FilterDefinition filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return UpdateOne(filter, field, value, null, cancellationToken); } /// - public virtual bool UpdateOne(FilterDefinition filter, Expression> field, TField value, string partitionKey) + public virtual bool UpdateOne( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument { return UpdateOne(filter, field, value, partitionKey, CancellationToken.None); } /// - public virtual bool UpdateOne(FilterDefinition filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual bool UpdateOne( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return MongoDbUpdater.UpdateOne(filter, field, value, partitionKey, cancellationToken); @@ -159,119 +187,187 @@ namespace MongoDbGenericRepository } /// - public virtual bool UpdateOne(Expression> filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual bool UpdateOne( + Expression> filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return UpdateOne(filter, field, value, null, cancellationToken); } /// - public virtual bool UpdateOne(Expression> filter, Expression> field, TField value, string partitionKey) + public virtual bool UpdateOne( + Expression> filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument { return UpdateOne(filter, field, value, partitionKey, CancellationToken.None); } /// - public virtual bool UpdateOne(Expression> filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual bool UpdateOne( + Expression> filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return MongoDbUpdater.UpdateOne(filter, field, value, partitionKey, cancellationToken); } /// - public virtual async Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value) + public virtual async Task UpdateOneAsync( + FilterDefinition filter, + Expression> field, + TField value) where TDocument : IDocument { return await UpdateOneAsync(filter, field, value, null, CancellationToken.None); } /// - public virtual async Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual async Task UpdateOneAsync( + FilterDefinition filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return await UpdateOneAsync(filter, field, value, null, cancellationToken); } /// - public virtual async Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey) + public virtual async Task UpdateOneAsync( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument { return await UpdateOneAsync(filter, field, value, partitionKey, CancellationToken.None); } /// - public virtual async Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual async Task UpdateOneAsync( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbUpdater.UpdateOneAsync(filter, field, value, partitionKey, cancellationToken); } /// - public virtual async Task UpdateOneAsync(Expression> filter, Expression> field, TField value) + public virtual async Task UpdateOneAsync( + Expression> filter, + Expression> field, + TField value) where TDocument : IDocument { return await UpdateOneAsync(filter, field, value, null, CancellationToken.None); } /// - public virtual async Task UpdateOneAsync(Expression> filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual async Task UpdateOneAsync( + Expression> filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return await UpdateOneAsync(filter, field, value, null, cancellationToken); } /// - public virtual async Task UpdateOneAsync(Expression> filter, Expression> field, TField value, string partitionKey) + public virtual async Task UpdateOneAsync( + Expression> filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument { return await UpdateOneAsync(filter, field, value, partitionKey, CancellationToken.None); } /// - public virtual async Task UpdateOneAsync(Expression> filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual async Task UpdateOneAsync( + Expression> filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbUpdater.UpdateOneAsync(filter, field, value, partitionKey, cancellationToken); } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + Expression> field, + TField value) where TDocument : IDocument { return await UpdateManyAsync(filter, field, value, null, CancellationToken.None); } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return await UpdateManyAsync(filter, field, value, null, cancellationToken); } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument { return await UpdateManyAsync(filter, field, value, partitionKey, CancellationToken.None); } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbUpdater.UpdateManyAsync(filter, field, value, partitionKey, cancellationToken); } /// - public virtual async Task UpdateManyAsync(Expression> filter, Expression> field, TField value) + public virtual async Task UpdateManyAsync( + Expression> filter, + Expression> field, + TField value) where TDocument : IDocument { return await UpdateManyAsync(filter, field, value, null, CancellationToken.None); } /// - public virtual async Task UpdateManyAsync(Expression> filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + Expression> filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return await UpdateManyAsync(filter, field, value, null, cancellationToken); @@ -279,14 +375,23 @@ namespace MongoDbGenericRepository /// - public virtual async Task UpdateManyAsync(Expression> filter, Expression> field, TField value, string partitionKey) + public virtual async Task UpdateManyAsync( + Expression> filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument { return await UpdateManyAsync(filter, field, value, partitionKey, CancellationToken.None); } /// - public virtual async Task UpdateManyAsync(Expression> filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + Expression> filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbUpdater.UpdateManyAsync(filter, field, value, partitionKey, cancellationToken); @@ -300,21 +405,31 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, UpdateDefinition updateDefinition, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + UpdateDefinition updateDefinition, + CancellationToken cancellationToken) where TDocument : IDocument { return await UpdateManyAsync(filter, updateDefinition, null, cancellationToken); } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + UpdateDefinition updateDefinition, + string partitionKey) where TDocument : IDocument { return await UpdateManyAsync(filter, updateDefinition, partitionKey, CancellationToken.None); } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + UpdateDefinition updateDefinition, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbUpdater.UpdateManyAsync(filter, updateDefinition, partitionKey, cancellationToken); @@ -328,21 +443,31 @@ namespace MongoDbGenericRepository } /// - public async Task UpdateManyAsync(Expression> filter, UpdateDefinition updateDefinition, CancellationToken cancellationToken) + public async Task UpdateManyAsync( + Expression> filter, + UpdateDefinition updateDefinition, + CancellationToken cancellationToken) where TDocument : IDocument { return await UpdateManyAsync(filter, updateDefinition, null, cancellationToken); } /// - public async Task UpdateManyAsync(Expression> filter, UpdateDefinition updateDefinition, string partitionKey) + public async Task UpdateManyAsync( + Expression> filter, + UpdateDefinition updateDefinition, + string partitionKey) where TDocument : IDocument { return await UpdateManyAsync(filter, updateDefinition, partitionKey, CancellationToken.None); } /// - public async Task UpdateManyAsync(Expression> filter, UpdateDefinition updateDefinition, string partitionKey, CancellationToken cancellationToken) + public async Task UpdateManyAsync( + Expression> filter, + UpdateDefinition updateDefinition, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbUpdater.UpdateManyAsync(filter, updateDefinition, partitionKey, cancellationToken); @@ -356,21 +481,34 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(FilterDefinition filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual long UpdateMany( + FilterDefinition filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return UpdateMany(filter, field, value, null, cancellationToken); } /// - public virtual long UpdateMany(FilterDefinition filter, Expression> field, TField value, string partitionKey) + public virtual long UpdateMany( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument { return UpdateMany(filter, field, value, partitionKey, CancellationToken.None); } /// - public virtual long UpdateMany(FilterDefinition filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual long UpdateMany( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return MongoDbUpdater.UpdateMany(filter, field, value, partitionKey, cancellationToken); @@ -384,21 +522,34 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(Expression> filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual long UpdateMany( + Expression> filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return UpdateMany(filter, field, value, null, cancellationToken); } /// - public virtual long UpdateMany(Expression> filter, Expression> field, TField value, string partitionKey) + public virtual long UpdateMany( + Expression> filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument { return UpdateMany(filter, field, value, partitionKey, CancellationToken.None); } /// - public virtual long UpdateMany(Expression> filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual long UpdateMany( + Expression> filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return MongoDbUpdater.UpdateMany(filter, field, value, partitionKey, cancellationToken); @@ -412,7 +563,10 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(FilterDefinition filter, UpdateDefinition updateDefinition, CancellationToken cancellationToken) + public virtual long UpdateMany( + FilterDefinition filter, + UpdateDefinition updateDefinition, + CancellationToken cancellationToken) where TDocument : IDocument { return UpdateMany(filter, updateDefinition, null, cancellationToken); @@ -426,7 +580,11 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey, CancellationToken cancellationToken) + public virtual long UpdateMany( + FilterDefinition filter, + UpdateDefinition updateDefinition, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return MongoDbUpdater.UpdateMany(filter, updateDefinition, partitionKey, cancellationToken); @@ -440,7 +598,10 @@ namespace MongoDbGenericRepository } /// - public long UpdateMany(Expression> filter, UpdateDefinition updateDefinition, CancellationToken cancellationToken) + public long UpdateMany( + Expression> filter, + UpdateDefinition updateDefinition, + CancellationToken cancellationToken) where TDocument : IDocument { return UpdateMany(filter, updateDefinition, null, cancellationToken); @@ -454,7 +615,11 @@ namespace MongoDbGenericRepository } /// - public long UpdateMany(Expression> filter, UpdateDefinition updateDefinition, string partitionKey, CancellationToken cancellationToken) + public long UpdateMany( + Expression> filter, + UpdateDefinition updateDefinition, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return MongoDbUpdater.UpdateMany(filter, updateDefinition, partitionKey, cancellationToken); @@ -505,7 +670,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateOneAsync(TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken) + public virtual async Task UpdateOneAsync( + TDocument documentToModify, + UpdateDefinition update, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -537,7 +705,11 @@ namespace MongoDbGenericRepository } /// - public virtual bool UpdateOne(TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken) + public virtual bool UpdateOne( + TDocument documentToModify, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -545,7 +717,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateOneAsync(TDocument documentToModify, Expression> field, TField value) + public virtual async Task UpdateOneAsync( + TDocument documentToModify, + Expression> field, + TField value) where TDocument : IDocument where TKey : IEquatable { @@ -553,7 +728,11 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateOneAsync(TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken) + public virtual async Task UpdateOneAsync( + TDocument documentToModify, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -569,7 +748,11 @@ namespace MongoDbGenericRepository } /// - public virtual bool UpdateOne(FilterDefinition filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual bool UpdateOne( + FilterDefinition filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -577,7 +760,11 @@ namespace MongoDbGenericRepository } /// - public virtual bool UpdateOne(FilterDefinition filter, Expression> field, TField value, string partitionKey) + public virtual bool UpdateOne( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument where TKey : IEquatable { @@ -585,7 +772,12 @@ namespace MongoDbGenericRepository } /// - public virtual bool UpdateOne(FilterDefinition filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual bool UpdateOne( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -593,7 +785,10 @@ namespace MongoDbGenericRepository } /// - public virtual bool UpdateOne(Expression> filter, Expression> field, TField value) + public virtual bool UpdateOne( + Expression> filter, + Expression> field, + TField value) where TDocument : IDocument where TKey : IEquatable { @@ -601,7 +796,11 @@ namespace MongoDbGenericRepository } /// - public virtual bool UpdateOne(Expression> filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual bool UpdateOne( + Expression> filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -609,7 +808,11 @@ namespace MongoDbGenericRepository } /// - public virtual bool UpdateOne(Expression> filter, Expression> field, TField value, string partitionKey) + public virtual bool UpdateOne( + Expression> filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument where TKey : IEquatable { @@ -617,7 +820,12 @@ namespace MongoDbGenericRepository } /// - public virtual bool UpdateOne(Expression> filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual bool UpdateOne( + Expression> filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -625,7 +833,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value) + public virtual async Task UpdateOneAsync( + FilterDefinition filter, + Expression> field, + TField value) where TDocument : IDocument where TKey : IEquatable { @@ -633,7 +844,11 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual async Task UpdateOneAsync( + FilterDefinition filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -641,7 +856,11 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey) + public virtual async Task UpdateOneAsync( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument where TKey : IEquatable { @@ -649,7 +868,12 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual async Task UpdateOneAsync( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -657,7 +881,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateOneAsync(Expression> filter, Expression> field, TField value) + public virtual async Task UpdateOneAsync( + Expression> filter, + Expression> field, + TField value) where TDocument : IDocument where TKey : IEquatable { @@ -665,7 +892,11 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateOneAsync(Expression> filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual async Task UpdateOneAsync( + Expression> filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -673,7 +904,11 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateOneAsync(Expression> filter, Expression> field, TField value, string partitionKey) + public virtual async Task UpdateOneAsync( + Expression> filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument where TKey : IEquatable { @@ -681,15 +916,28 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateOneAsync(Expression> filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual async Task UpdateOneAsync( + Expression> filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { - return await MongoDbUpdater.UpdateOneAsync(Builders.Filter.Where(filter), field, value, partitionKey, cancellationToken); + return await MongoDbUpdater.UpdateOneAsync( + Builders.Filter.Where(filter), + field, + value, + partitionKey, + cancellationToken); } /// - public virtual async Task UpdateManyAsync(Expression> filter, Expression> field, TField value) + public virtual async Task UpdateManyAsync( + Expression> filter, + Expression> field, + TField value) where TDocument : IDocument where TKey : IEquatable { @@ -697,7 +945,11 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateManyAsync(Expression> filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + Expression> filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -705,7 +957,11 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateManyAsync(Expression> filter, Expression> field, TField value, string partitionKey) + public virtual async Task UpdateManyAsync( + Expression> filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument where TKey : IEquatable { @@ -713,7 +969,12 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateManyAsync(Expression> filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + Expression> filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -721,7 +982,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + Expression> field, + TField value) where TDocument : IDocument where TKey : IEquatable { @@ -729,7 +993,11 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -737,7 +1005,11 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument where TKey : IEquatable { @@ -745,7 +1017,12 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -761,7 +1038,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, UpdateDefinition updateDefinition, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + UpdateDefinition updateDefinition, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -769,7 +1049,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + UpdateDefinition updateDefinition, + string partitionKey) where TDocument : IDocument where TKey : IEquatable { @@ -777,7 +1060,11 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + UpdateDefinition updateDefinition, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -793,7 +1080,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateManyAsync(Expression> filter, UpdateDefinition updateDefinition, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + Expression> filter, + UpdateDefinition updateDefinition, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -801,7 +1091,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateManyAsync(Expression> filter, UpdateDefinition updateDefinition, string partitionKey) + public virtual async Task UpdateManyAsync( + Expression> filter, + UpdateDefinition updateDefinition, + string partitionKey) where TDocument : IDocument where TKey : IEquatable { @@ -809,7 +1102,11 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateManyAsync(Expression> filter, UpdateDefinition updateDefinition, string partitionKey, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + Expression> filter, + UpdateDefinition updateDefinition, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -817,7 +1114,10 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(Expression> filter, Expression> field, TField value) + public virtual long UpdateMany( + Expression> filter, + Expression> field, + TField value) where TDocument : IDocument where TKey : IEquatable { @@ -825,7 +1125,11 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(Expression> filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual long UpdateMany( + Expression> filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -833,7 +1137,11 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(Expression> filter, Expression> field, TField value, string partitionKey) + public virtual long UpdateMany( + Expression> filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument where TKey : IEquatable { @@ -841,7 +1149,12 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(Expression> filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual long UpdateMany( + Expression> filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -857,7 +1170,11 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(FilterDefinition filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual long UpdateMany( + FilterDefinition filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -865,7 +1182,11 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(FilterDefinition filter, Expression> field, TField value, string partitionKey) + public virtual long UpdateMany( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument where TKey : IEquatable { @@ -873,7 +1194,12 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(FilterDefinition filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual long UpdateMany( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -889,7 +1215,10 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(Expression> filter, UpdateDefinition updateDefinition, CancellationToken cancellationToken) + public virtual long UpdateMany( + Expression> filter, + UpdateDefinition updateDefinition, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -897,7 +1226,10 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(Expression> filter, UpdateDefinition updateDefinition, string partitionKey) + public virtual long UpdateMany( + Expression> filter, + UpdateDefinition updateDefinition, + string partitionKey) where TDocument : IDocument where TKey : IEquatable { @@ -905,7 +1237,11 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(Expression> filter, UpdateDefinition updateDefinition, string partitionKey, CancellationToken cancellationToken) + public virtual long UpdateMany( + Expression> filter, + UpdateDefinition updateDefinition, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -921,7 +1257,10 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(FilterDefinition filter, UpdateDefinition updateDefinition, CancellationToken cancellationToken) + public virtual long UpdateMany( + FilterDefinition filter, + UpdateDefinition updateDefinition, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -937,7 +1276,11 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey, CancellationToken cancellationToken) + public virtual long UpdateMany( + FilterDefinition filter, + UpdateDefinition updateDefinition, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable { @@ -946,5 +1289,4 @@ namespace MongoDbGenericRepository #endregion Update } - } \ No newline at end of file diff --git a/MongoDbGenericRepository/DataAccess/Read/IMongoDbReader.cs b/MongoDbGenericRepository/DataAccess/Read/IMongoDbReader.cs index 7230aa3..db14f81 100644 --- a/MongoDbGenericRepository/DataAccess/Read/IMongoDbReader.cs +++ b/MongoDbGenericRepository/DataAccess/Read/IMongoDbReader.cs @@ -11,12 +11,12 @@ using MongoDbGenericRepository.Models; namespace MongoDbGenericRepository.DataAccess.Read { /// - /// A interface for accessing the Database and its Collections. + /// A interface for accessing the Database and its Collections. /// public interface IMongoDbReader : IDataAccessBase { /// - /// Asynchronously returns a projected document matching the filter condition. + /// Asynchronously returns a projected document matching the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -35,7 +35,7 @@ namespace MongoDbGenericRepository.DataAccess.Read where TProjection : class; /// - /// Returns a projected document matching the filter condition. + /// Returns a projected document matching the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -43,13 +43,18 @@ namespace MongoDbGenericRepository.DataAccess.Read /// A LINQ expression filter. /// The projection expression. /// An optional partition key. - TProjection ProjectOne(Expression> filter, Expression> projection, string partitionKey = null, CancellationToken cancellationToken = default) + /// The cancellation token. + TProjection ProjectOne( + Expression> filter, + Expression> projection, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable where TProjection : class; /// - /// Asynchronously returns a list of projected documents matching the filter condition. + /// Asynchronously returns a list of projected documents matching the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -68,7 +73,7 @@ namespace MongoDbGenericRepository.DataAccess.Read where TProjection : class; /// - /// Asynchronously returns a list of projected documents matching the filter condition. + /// Asynchronously returns a list of projected documents matching the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -76,14 +81,19 @@ namespace MongoDbGenericRepository.DataAccess.Read /// The document filter. /// The projection expression. /// An optional partition key. - List ProjectMany(Expression> filter, Expression> projection, string partitionKey = null, CancellationToken cancellationToken = default) + /// The cancellation token. + List ProjectMany( + Expression> filter, + Expression> projection, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable where TProjection : class; /// - /// Groups a collection of documents given a grouping criteria, - /// and returns a dictionary of listed document groups with keys having the different values of the grouping criteria. + /// Groups a collection of documents given a grouping criteria, + /// and returns a dictionary of listed document groups with keys having the different values of the grouping criteria. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -92,17 +102,19 @@ namespace MongoDbGenericRepository.DataAccess.Read /// The grouping criteria. /// The projected group result. /// The partition key of your document, if any. + /// The cancellation token. List GroupBy( Expression> groupingCriteria, Expression, TProjection>> groupProjection, - string partitionKey = null, CancellationToken cancellationToken = default) + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable where TProjection : class, new(); /// - /// Groups filtered a collection of documents given a grouping criteria, - /// and returns a dictionary of listed document groups with keys having the different values of the grouping criteria. + /// Groups filtered a collection of documents given a grouping criteria, + /// and returns a dictionary of listed document groups with keys having the different values of the grouping criteria. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -112,18 +124,20 @@ namespace MongoDbGenericRepository.DataAccess.Read /// The grouping criteria. /// The projected group result. /// The partition key of your document, if any. + /// The cancellation token. List GroupBy( Expression> filter, Expression> selector, Expression, TProjection>> projection, - string partitionKey = null, CancellationToken cancellationToken = default) + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable where TProjection : class, new(); /// - /// Groups filtered a collection of documents given a grouping criteria, - /// and returns a dictionary of listed document groups with keys having the different values of the grouping criteria. + /// Groups filtered a collection of documents given a grouping criteria, + /// and returns a dictionary of listed document groups with keys having the different values of the grouping criteria. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -145,7 +159,7 @@ namespace MongoDbGenericRepository.DataAccess.Read where TProjection : class, new(); /// - /// Asynchronously returns a paginated list of the documents matching the filter condition. + /// Asynchronously returns a paginated list of the documents matching the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -168,7 +182,7 @@ namespace MongoDbGenericRepository.DataAccess.Read where TKey : IEquatable; /// - /// Asynchronously returns a paginated list of the documents matching the filter condition. + /// Asynchronously returns a paginated list of the documents matching the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -189,7 +203,7 @@ namespace MongoDbGenericRepository.DataAccess.Read where TKey : IEquatable; /// - /// Asynchronously returns one document given its id. + /// Asynchronously returns one document given its id. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -201,18 +215,19 @@ namespace MongoDbGenericRepository.DataAccess.Read where TKey : IEquatable; /// - /// Returns one document given its id. + /// Returns one document given its id. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The Id of the document you want to get. /// An optional partition key. + /// The cancellation token. TDocument GetById(TKey id, string partitionKey = null, CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Asynchronously returns one document given filter definition. + /// Asynchronously returns one document given filter definition. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -220,49 +235,60 @@ namespace MongoDbGenericRepository.DataAccess.Read /// A mongodb filter option. /// An optional partition key. /// An optional cancellation Token. - Task GetOneAsync(FilterDefinition condition, FindOptions findOption = null, + Task GetOneAsync( + FilterDefinition condition, + FindOptions findOption = null, string partitionKey = null, CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Asynchronously returns one document given an expression filter. + /// Asynchronously returns one document given an expression filter. /// /// The type representing a Document. /// The type of the primary key for a Document. /// A LINQ expression filter. /// An optional partition key. /// An optional cancellation Token. - Task GetOneAsync(Expression> filter, string partitionKey = null, CancellationToken cancellationToken = default) + Task GetOneAsync( + Expression> filter, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Returns one document given filter definition. + /// Returns one document given filter definition. /// /// The type representing a Document. /// The type of the primary key for a Document. /// A mongodb filter definition. /// A mongodb filter option. /// An optional partition key. - TDocument GetOne(FilterDefinition condition, FindOptions findOption = null, string partitionKey = null, CancellationToken cancellationToken = default) + /// The cancellation token. + TDocument GetOne( + FilterDefinition condition, + FindOptions findOption = null, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Returns one document given an expression filter. + /// Returns one document given an expression filter. /// /// The type representing a Document. /// The type of the primary key for a Document. /// A LINQ expression filter. /// An optional partition key. + /// The cancellation token. TDocument GetOne(Expression> filter, string partitionKey = null, CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Returns a collection cursor. + /// Returns a collection cursor. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -273,7 +299,7 @@ namespace MongoDbGenericRepository.DataAccess.Read where TKey : IEquatable; /// - /// Returns true if any of the document of the collection matches the filter condition. + /// Returns true if any of the document of the collection matches the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -281,49 +307,60 @@ namespace MongoDbGenericRepository.DataAccess.Read /// A mongodb counting option. /// An optional partition key. /// An optional cancellation Token. - Task AnyAsync(FilterDefinition condition, CountOptions countOption = null, string partitionKey = null, + Task AnyAsync( + FilterDefinition condition, + CountOptions countOption = null, + string partitionKey = null, CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Returns true if any of the document of the collection matches the filter condition. + /// Returns true if any of the document of the collection matches the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. /// A LINQ expression filter. /// An optional partition key. /// An optional cancellation Token. - Task AnyAsync(Expression> filter, string partitionKey = null, CancellationToken cancellationToken = default) + Task AnyAsync( + Expression> filter, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Returns true if any of the document of the collection matches the filter condition. + /// Returns true if any of the document of the collection matches the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. /// A mongodb filter definition. /// A mongodb counting option. /// An optional partition key. - bool Any(FilterDefinition condition, CountOptions countOption = null, - string partitionKey = null, CancellationToken cancellationToken = default) + /// The cancellation token. + bool Any( + FilterDefinition condition, + CountOptions countOption = null, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Returns true if any of the document of the collection matches the filter condition. + /// Returns true if any of the document of the collection matches the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. /// A LINQ expression filter. /// An optional partition key. + /// The cancellation token. bool Any(Expression> filter, string partitionKey = null, CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Asynchronously returns a list of the documents matching the filter condition. + /// Asynchronously returns a list of the documents matching the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -331,49 +368,63 @@ namespace MongoDbGenericRepository.DataAccess.Read /// A mongodb filter option. /// An optional partition key. /// An optional cancellation Token. - Task> GetAllAsync(FilterDefinition condition, - FindOptions findOption = null, string partitionKey = null, CancellationToken cancellationToken = default) + Task> GetAllAsync( + FilterDefinition condition, + FindOptions findOption = null, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Asynchronously returns a list of the documents matching the filter condition. + /// Asynchronously returns a list of the documents matching the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. /// A LINQ expression filter. /// An optional partition key. /// An optional cancellation Token. - Task> GetAllAsync(Expression> filter, string partitionKey = null, CancellationToken cancellationToken = default) + Task> GetAllAsync( + Expression> filter, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Returns a list of the documents matching the filter condition. + /// Returns a list of the documents matching the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. /// A mongodb filter definition. /// A mongodb filter option. /// An optional partition key. - List GetAll(FilterDefinition condition, FindOptions findOption = null, - string partitionKey = null, CancellationToken cancellationToken = default) + /// The cancellation token. + List GetAll( + FilterDefinition condition, + FindOptions findOption = null, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Returns a list of the documents matching the filter condition. + /// Returns a list of the documents matching the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. /// A LINQ expression filter. /// An optional partition key. - List GetAll(Expression> filter, string partitionKey = null, CancellationToken cancellationToken = default) + /// The cancellation token. + List GetAll( + Expression> filter, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Asynchronously counts how many documents match the filter condition. + /// Asynchronously counts how many documents match the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -381,49 +432,61 @@ namespace MongoDbGenericRepository.DataAccess.Read /// A mongodb counting option. /// An optional partitionKey /// An optional cancellation Token. - Task CountAsync(FilterDefinition condition, CountOptions countOption = null, - string partitionKey = null, CancellationToken cancellationToken = default) + Task CountAsync( + FilterDefinition condition, + CountOptions countOption = null, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Asynchronously counts how many documents match the filter condition. + /// Asynchronously counts how many documents match the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. /// A LINQ expression filter. /// An optional partitionKey /// An optional cancellation Token. - Task CountAsync(Expression> filter, string partitionKey = null, CancellationToken cancellationToken = default) + Task CountAsync( + Expression> filter, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Counts how many documents match the filter condition. + /// Counts how many documents match the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. /// A mongodb filter definition. /// A mongodb counting option. /// An optional partitionKey - long Count(FilterDefinition condition, CountOptions countOption = null, - string partitionKey = null, CancellationToken cancellationToken = default) + /// The cancellation token. + long Count( + FilterDefinition condition, + CountOptions countOption = null, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Counts how many documents match the filter condition. + /// Counts how many documents match the filter condition. /// /// The type representing a Document. /// The type of the primary key for a Document. /// A LINQ expression filter. /// An optional partitionKey + /// The cancellation token. long Count(Expression> filter, string partitionKey = null, CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + /// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the + /// filter. /// /// The document type. /// The type of the primary key. @@ -431,24 +494,35 @@ namespace MongoDbGenericRepository.DataAccess.Read /// A property selector to order by descending. /// An optional partitionKey. /// An optional cancellation Token. - Task GetByMaxAsync(Expression> filter, Expression> maxValueSelector, string partitionKey = null, CancellationToken cancellationToken = default) + Task GetByMaxAsync( + Expression> filter, + Expression> maxValueSelector, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + /// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the + /// filter. /// /// The document type. /// The type of the primary key. /// A LINQ expression filter. /// A property selector to order by descending. /// An optional partitionKey. - TDocument GetByMax(Expression> filter, Expression> maxValueSelector, string partitionKey = null, CancellationToken cancellationToken = default) + /// The cancellation token. + TDocument GetByMax( + Expression> filter, + Expression> maxValueSelector, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter. + /// Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the + /// filter. /// /// The document type. /// The type of the primary key. @@ -456,24 +530,34 @@ namespace MongoDbGenericRepository.DataAccess.Read /// A property selector to order by ascending. /// An optional partitionKey. /// An optional cancellation Token. - Task GetByMinAsync(Expression> filter, Expression> minValueSelector, string partitionKey = null, CancellationToken cancellationToken = default) + Task GetByMinAsync( + Expression> filter, + Expression> minValueSelector, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter. + /// Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the + /// filter. /// /// The document type. /// The type of the primary key. /// A LINQ expression filter. /// A property selector to order by ascending. /// An optional partitionKey. - TDocument GetByMin(Expression> filter, Expression> minValueSelector, string partitionKey = null, CancellationToken cancellationToken = default) + /// The cancellation token. + TDocument GetByMin( + Expression> filter, + Expression> minValueSelector, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + /// Gets the maximum value of a property in a mongodb collections that is satisfying the filter. /// /// The document type. /// The type of the primary key. @@ -482,12 +566,16 @@ namespace MongoDbGenericRepository.DataAccess.Read /// A property selector to order by ascending. /// An optional partitionKey. /// An optional cancellation Token. - Task GetMaxValueAsync(Expression> filter, Expression> maxValueSelector, string partitionKey = null, CancellationToken cancellationToken = default) + Task GetMaxValueAsync( + Expression> filter, + Expression> maxValueSelector, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + /// Gets the maximum value of a property in a mongodb collections that is satisfying the filter. /// /// The document type. /// The type of the primary key. @@ -495,12 +583,17 @@ namespace MongoDbGenericRepository.DataAccess.Read /// A LINQ expression filter. /// A property selector to order by ascending. /// An optional partitionKey. - TValue GetMaxValue(Expression> filter, Expression> maxValueSelector, string partitionKey = null, CancellationToken cancellationToken = default) + /// The cancellation token. + TValue GetMaxValue( + Expression> filter, + Expression> maxValueSelector, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + /// Gets the minimum value of a property in a mongodb collections that is satisfying the filter. /// /// The document type. /// The type of the primary key. @@ -509,12 +602,16 @@ namespace MongoDbGenericRepository.DataAccess.Read /// A property selector to order by ascending. /// An optional partition key. /// An optional cancellation Token. - Task GetMinValueAsync(Expression> filter, Expression> minValueSelector, string partitionKey = null, CancellationToken cancellationToken = default) + Task GetMinValueAsync( + Expression> filter, + Expression> minValueSelector, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + /// Gets the minimum value of a property in a mongodb collections that is satisfying the filter. /// /// The document type. /// The type of the primary key. @@ -522,12 +619,17 @@ namespace MongoDbGenericRepository.DataAccess.Read /// A LINQ expression filter. /// A property selector to order by ascending. /// An optional partition key. - TValue GetMinValue(Expression> filter, Expression> minValueSelector, string partitionKey = null, CancellationToken cancellationToken = default) + /// The cancellation token. + TValue GetMinValue( + Expression> filter, + Expression> minValueSelector, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Sums the values of a selected field for a given filtered collection of documents. + /// Sums the values of a selected field for a given filtered collection of documents. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -535,7 +637,8 @@ namespace MongoDbGenericRepository.DataAccess.Read /// The field you want to sum. /// The partition key of your document, if any. /// An optional cancellation Token. - Task SumByAsync(Expression> filter, + Task SumByAsync( + Expression> filter, Expression> selector, string partitionKey = null, CancellationToken cancellationToken = default) @@ -543,7 +646,7 @@ namespace MongoDbGenericRepository.DataAccess.Read where TKey : IEquatable; /// - /// Sums the values of a selected field for a given filtered collection of documents. + /// Sums the values of a selected field for a given filtered collection of documents. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -551,35 +654,39 @@ namespace MongoDbGenericRepository.DataAccess.Read /// The field you want to sum. /// The partition key of your document, if any. /// An optional cancellation Token. - Task SumByAsync(Expression> filter, + Task SumByAsync( + Expression> filter, Expression> selector, - string partitionKey = null, CancellationToken cancellationToken = default) + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Sums the values of a selected field for a given filtered collection of documents. + /// Sums the values of a selected field for a given filtered collection of documents. /// /// The type representing a Document. /// The type of the primary key for a Document. /// A LINQ expression filter. /// The field you want to sum. /// The partition key of your document, if any. - int SumBy(Expression> filter, + int SumBy( + Expression> filter, Expression> selector, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable; /// - /// Sums the values of a selected field for a given filtered collection of documents. + /// Sums the values of a selected field for a given filtered collection of documents. /// /// The type representing a Document. /// The type of the primary key for a Document. /// A LINQ expression filter. /// The field you want to sum. /// The partition key of your document, if any. - decimal SumBy(Expression> filter, + decimal SumBy( + Expression> filter, Expression> selector, string partitionKey = null) where TDocument : IDocument diff --git a/MongoDbGenericRepository/DataAccess/Read/MongoDbReader.GroupBy.cs b/MongoDbGenericRepository/DataAccess/Read/MongoDbReader.GroupBy.cs index 35185b3..c808147 100644 --- a/MongoDbGenericRepository/DataAccess/Read/MongoDbReader.GroupBy.cs +++ b/MongoDbGenericRepository/DataAccess/Read/MongoDbReader.GroupBy.cs @@ -15,7 +15,8 @@ namespace MongoDbGenericRepository.DataAccess.Read public virtual List GroupBy( Expression> groupingCriteria, Expression, TProjection>> groupProjection, - string partitionKey = null, CancellationToken cancellationToken = default) + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable where TProjection : class, new() @@ -23,7 +24,7 @@ namespace MongoDbGenericRepository.DataAccess.Read return HandlePartitioned(partitionKey) .Aggregate() .Group(groupingCriteria, groupProjection) - .ToList(cancellationToken:cancellationToken); + .ToList(cancellationToken); } /// diff --git a/MongoDbGenericRepository/DataAccess/Update/IMongoDbUpdater.cs b/MongoDbGenericRepository/DataAccess/Update/IMongoDbUpdater.cs index 1d96fca..fa15af7 100644 --- a/MongoDbGenericRepository/DataAccess/Update/IMongoDbUpdater.cs +++ b/MongoDbGenericRepository/DataAccess/Update/IMongoDbUpdater.cs @@ -9,12 +9,12 @@ using MongoDbGenericRepository.Models; namespace MongoDbGenericRepository.DataAccess.Update { /// - /// A interface for updating documents in MongoDb. + /// A interface for updating documents in MongoDb. /// public interface IMongoDbUpdater : IDataAccessBase { /// - /// Asynchronously Updates a document. + /// Asynchronously Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -25,19 +25,22 @@ namespace MongoDbGenericRepository.DataAccess.Update where TKey : IEquatable; /// - /// 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. /// /// 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. /// An optional cancellation token. - Task UpdateOneAsync(TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken = default) + Task UpdateOneAsync( + TDocument documentToModify, + UpdateDefinition update, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// 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. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -46,12 +49,16 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The field selector. /// The new value of the property field. /// An optional cancellation token. - Task UpdateOneAsync(TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken = default) + Task UpdateOneAsync( + TDocument documentToModify, + Expression> field, + TField value, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// 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. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -61,12 +68,17 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The new value of the property field. /// The value of the partition key. /// An optional cancellation token. - Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default) + Task UpdateOneAsync( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// For the entity 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. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -76,12 +88,17 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The new value of the property field. /// The partition key for the document. /// An optional cancellation token. - Task UpdateOneAsync(Expression> filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default) + Task UpdateOneAsync( + Expression> filter, + Expression> field, + TField value, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -94,7 +111,7 @@ namespace MongoDbGenericRepository.DataAccess.Update where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -103,12 +120,16 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The update definition. /// The optional cancellation token. /// - Task UpdateOneAsync(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken = default) + Task UpdateOneAsync( + IClientSessionHandle session, + TDocument documentToModify, + UpdateDefinition update, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -119,12 +140,17 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The value of the field. /// The optional cancellation token. /// - Task UpdateOneAsync(IClientSessionHandle session, TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken = default) + Task UpdateOneAsync( + IClientSessionHandle session, + TDocument documentToModify, + Expression> field, + TField value, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -136,12 +162,18 @@ 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) + Task UpdateOneAsync( + IClientSessionHandle session, + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -153,12 +185,18 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The optional partition key. /// The optional cancellation token. /// - Task UpdateOneAsync(IClientSessionHandle session, Expression> filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default) + Task UpdateOneAsync( + IClientSessionHandle session, + Expression> filter, + Expression> field, + TField value, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -169,7 +207,7 @@ namespace MongoDbGenericRepository.DataAccess.Update where TKey : IEquatable; /// - /// 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. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -181,7 +219,7 @@ namespace MongoDbGenericRepository.DataAccess.Update where TKey : IEquatable; /// - /// 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. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -190,12 +228,16 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The field selector. /// The new value of the property field. /// The optional cancellation token. - bool UpdateOne(TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken = default) + bool UpdateOne( + TDocument documentToModify, + Expression> field, + TField value, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates the property field with the given value. + /// Updates the property field with the given value. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -205,12 +247,17 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The new value of the property field. /// The value of the partition key. /// The optional cancellation token. - bool UpdateOne(FilterDefinition filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default) + bool UpdateOne( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// For the entity 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. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -220,12 +267,17 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The new value of the property field. /// The partition key for the document. /// The optional cancellation token. - bool UpdateOne(Expression> filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default) + bool UpdateOne( + Expression> filter, + Expression> field, + TField value, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -238,7 +290,7 @@ namespace MongoDbGenericRepository.DataAccess.Update where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -247,12 +299,16 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The update definition. /// The optional cancellation token. /// - bool UpdateOne(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken = default) + bool UpdateOne( + IClientSessionHandle session, + TDocument documentToModify, + UpdateDefinition update, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -263,12 +319,17 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The value of the field. /// The optional cancellation token. /// - bool UpdateOne(IClientSessionHandle session, TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken = default) + bool UpdateOne( + IClientSessionHandle session, + TDocument documentToModify, + Expression> field, + TField value, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -280,12 +341,18 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The optional partition key. /// The optional cancellation token. /// - bool UpdateOne(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default) + bool UpdateOne( + IClientSessionHandle session, + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// Updates a document. + /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -297,12 +364,18 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The optional partition key. /// The optional cancellation token. /// - bool UpdateOne(IClientSessionHandle session, Expression> filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default) + bool UpdateOne( + IClientSessionHandle session, + Expression> filter, + Expression> field, + TField value, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// 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. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -312,12 +385,17 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The new value of the property field. /// The partition key for the document. /// The optional cancellation token. - Task UpdateManyAsync(Expression> filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default) + Task UpdateManyAsync( + Expression> filter, + Expression> field, + TField value, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// 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. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -327,12 +405,17 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The new value of the property field. /// The value of the partition key. /// The optional cancellation token. - Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default) + Task UpdateManyAsync( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// For the entities selected by the filter, apply the update definition. + /// For the entities selected by the filter, apply the update definition. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -340,12 +423,16 @@ namespace MongoDbGenericRepository.DataAccess.Update /// the update definition /// The value of the partition key. /// The optional cancellation token. - Task UpdateManyAsync(Expression> filter, UpdateDefinition update, string partitionKey = null, CancellationToken cancellationToken = default) + Task UpdateManyAsync( + Expression> filter, + UpdateDefinition update, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// For the entities selected by the filter, apply the update definition. + /// For the entities selected by the filter, apply the update definition. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -353,12 +440,16 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The update definition. /// The value of the partition key. /// The optional cancellation token. - Task UpdateManyAsync(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey = null, CancellationToken cancellationToken = default) + Task UpdateManyAsync( + FilterDefinition filter, + UpdateDefinition updateDefinition, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// 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. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -368,12 +459,17 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The new value of the property field. /// The partition key for the document. /// The optional cancellation token. - long UpdateMany(Expression> filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default) + long UpdateMany( + Expression> filter, + Expression> field, + TField value, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// 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. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -383,12 +479,17 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The new value of the property field. /// The value of the partition key. /// The optional cancellation token. - long UpdateMany(FilterDefinition filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default) + long UpdateMany( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; /// - /// For the entities selected by the filter, apply the update definition. + /// For the entities selected by the filter, apply the update definition. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -396,7 +497,11 @@ namespace MongoDbGenericRepository.DataAccess.Update /// The update definition. /// The value of the partition key. /// The optional cancellation token. - long UpdateMany(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey = null, CancellationToken cancellationToken = default) + long UpdateMany( + FilterDefinition filter, + UpdateDefinition updateDefinition, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable; } diff --git a/MongoDbGenericRepository/DataAccess/Update/MongoDbUpdater.ClientSession.cs b/MongoDbGenericRepository/DataAccess/Update/MongoDbUpdater.ClientSession.cs index 8726c6f..ff78746 100644 --- a/MongoDbGenericRepository/DataAccess/Update/MongoDbUpdater.ClientSession.cs +++ b/MongoDbGenericRepository/DataAccess/Update/MongoDbUpdater.ClientSession.cs @@ -1,23 +1,26 @@ -using MongoDB.Driver; -using MongoDbGenericRepository.Models; -using System; +using System; using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; +using MongoDB.Driver; +using MongoDbGenericRepository.Models; namespace MongoDbGenericRepository.DataAccess.Update { public partial class MongoDbUpdater { /// - public virtual async Task UpdateOneAsync(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default) + public virtual async Task UpdateOneAsync( + IClientSessionHandle session, + TDocument modifiedDocument, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable { var filter = Builders.Filter.Eq("Id", modifiedDocument.Id); var updateRes = await HandlePartitioned(modifiedDocument) - .ReplaceOneAsync(session, filter, modifiedDocument, cancellationToken: cancellationToken) - .ConfigureAwait(false); + .ReplaceOneAsync(session, filter, modifiedDocument, cancellationToken: cancellationToken) + .ConfigureAwait(false); return updateRes.ModifiedCount == 1; } @@ -27,22 +30,32 @@ namespace MongoDbGenericRepository.DataAccess.Update where TKey : IEquatable { var filter = Builders.Filter.Eq("Id", modifiedDocument.Id); - var updateRes = HandlePartitioned(modifiedDocument).ReplaceOne(session, filter, modifiedDocument, cancellationToken: cancellationToken); + var updateRes = HandlePartitioned(modifiedDocument) + .ReplaceOne(session, filter, modifiedDocument, cancellationToken: cancellationToken); return updateRes.ModifiedCount == 1; } /// - public virtual async Task UpdateOneAsync(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken = default) + public virtual async Task UpdateOneAsync( + IClientSessionHandle session, + TDocument documentToModify, + UpdateDefinition update, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable { var filter = Builders.Filter.Eq("Id", documentToModify.Id); - var updateRes = await HandlePartitioned(documentToModify).UpdateOneAsync(session, filter, update, null, cancellationToken).ConfigureAwait(false); + var updateRes = await HandlePartitioned(documentToModify).UpdateOneAsync(session, filter, update, null, cancellationToken) + .ConfigureAwait(false); return updateRes.ModifiedCount == 1; } /// - public virtual bool UpdateOne(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken = default) + public virtual bool UpdateOne( + IClientSessionHandle session, + TDocument documentToModify, + UpdateDefinition update, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable { @@ -52,40 +65,67 @@ namespace MongoDbGenericRepository.DataAccess.Update } /// - public virtual async Task UpdateOneAsync(IClientSessionHandle session, TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken = default) + public virtual async Task UpdateOneAsync( + IClientSessionHandle session, + TDocument documentToModify, + Expression> field, + TField value, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable { var filter = Builders.Filter.Eq("Id", documentToModify.Id); var updateRes = await HandlePartitioned(documentToModify) - .UpdateOneAsync(session, filter, Builders.Update.Set(field, value), cancellationToken: cancellationToken) - .ConfigureAwait(false); + .UpdateOneAsync(session, filter, Builders.Update.Set(field, value), cancellationToken: cancellationToken) + .ConfigureAwait(false); return updateRes.ModifiedCount == 1; } /// - public virtual bool UpdateOne(IClientSessionHandle session, TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken = default) + public virtual bool UpdateOne( + IClientSessionHandle session, + TDocument documentToModify, + Expression> field, + TField value, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable { var filter = Builders.Filter.Eq("Id", documentToModify.Id); - var updateRes = HandlePartitioned(documentToModify).UpdateOne(session, filter, Builders.Update.Set(field, value), cancellationToken: cancellationToken); + var updateRes = HandlePartitioned(documentToModify).UpdateOne( + session, + filter, + Builders.Update.Set(field, value), + cancellationToken: cancellationToken); return updateRes.ModifiedCount == 1; } /// - public virtual async Task UpdateOneAsync(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default) + public virtual async Task UpdateOneAsync( + IClientSessionHandle session, + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable { var collection = string.IsNullOrEmpty(partitionKey) ? GetCollection() : GetCollection(partitionKey); - var updateRes = await collection.UpdateOneAsync(session, filter, Builders.Update.Set(field, value), cancellationToken: cancellationToken).ConfigureAwait(false); + var updateRes = await collection.UpdateOneAsync(session, filter, Builders.Update.Set(field, value), cancellationToken: cancellationToken) + .ConfigureAwait(false); return updateRes.ModifiedCount == 1; } /// - public virtual Task UpdateOneAsync(IClientSessionHandle session, Expression> filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default) + public virtual Task UpdateOneAsync( + IClientSessionHandle session, + Expression> filter, + Expression> field, + TField value, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable { @@ -93,7 +133,13 @@ namespace MongoDbGenericRepository.DataAccess.Update } /// - public virtual bool UpdateOne(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default) + public virtual bool UpdateOne( + IClientSessionHandle session, + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable { @@ -103,7 +149,13 @@ namespace MongoDbGenericRepository.DataAccess.Update } /// - public virtual bool UpdateOne(IClientSessionHandle session, Expression> filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default) + public virtual bool UpdateOne( + IClientSessionHandle session, + Expression> filter, + Expression> field, + TField value, + string partitionKey = null, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable { diff --git a/MongoDbGenericRepository/DataAccess/Update/MongoDbUpdater.cs b/MongoDbGenericRepository/DataAccess/Update/MongoDbUpdater.cs index b5ffa7b..ebb74ef 100644 --- a/MongoDbGenericRepository/DataAccess/Update/MongoDbUpdater.cs +++ b/MongoDbGenericRepository/DataAccess/Update/MongoDbUpdater.cs @@ -56,7 +56,10 @@ namespace MongoDbGenericRepository.DataAccess.Update } /// - public virtual bool UpdateOne(TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken = default) + public virtual bool UpdateOne( + TDocument documentToModify, + UpdateDefinition update, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable { @@ -83,12 +86,19 @@ namespace MongoDbGenericRepository.DataAccess.Update } /// - public virtual bool UpdateOne(TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken = default) + public virtual bool UpdateOne( + TDocument documentToModify, + Expression> field, + TField value, + CancellationToken cancellationToken = default) where TDocument : IDocument where TKey : IEquatable { var filter = Builders.Filter.Eq("Id", documentToModify.Id); - var updateRes = HandlePartitioned(documentToModify).UpdateOne(filter, Builders.Update.Set(field, value), cancellationToken: cancellationToken); + var updateRes = HandlePartitioned(documentToModify).UpdateOne( + filter, + Builders.Update.Set(field, value), + cancellationToken: cancellationToken); return updateRes.ModifiedCount == 1; } diff --git a/MongoDbGenericRepository/IBaseMongoRepository.Create.cs b/MongoDbGenericRepository/IBaseMongoRepository.Create.cs index 1b7243d..56be005 100644 --- a/MongoDbGenericRepository/IBaseMongoRepository.Create.cs +++ b/MongoDbGenericRepository/IBaseMongoRepository.Create.cs @@ -7,14 +7,14 @@ using MongoDbGenericRepository.Models; namespace MongoDbGenericRepository { /// - /// The IBaseMongoRepository_Create interface to expose document creation functionality - /// with document having an Id of type Guid. + /// The IBaseMongoRepository_Create interface to expose document creation functionality + /// with document having an Id of type Guid. /// public interface IBaseMongoRepository_Create : IBaseMongoRepository_Create { /// - /// Asynchronously adds a document to the collection. - /// Populates the Id and AddedAtUtc fields if necessary. + /// Asynchronously adds a document to the collection. + /// Populates the Id and AddedAtUtc fields if necessary. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -24,8 +24,8 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Asynchronously adds a document to the collection. - /// Populates the Id and AddedAtUtc fields if necessary. + /// Asynchronously adds a document to the collection. + /// Populates the Id and AddedAtUtc fields if necessary. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -36,8 +36,8 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Adds a document to the collection. - /// Populates the Id and AddedAtUtc fields if necessary. + /// Adds a document to the collection. + /// Populates the Id and AddedAtUtc fields if necessary. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -47,8 +47,8 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Adds a document to the collection. - /// Populates the Id and AddedAtUtc fields if necessary. + /// Adds a document to the collection. + /// Populates the Id and AddedAtUtc fields if necessary. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -59,8 +59,8 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Asynchronously adds a list of documents to the collection. - /// Populates the Id and AddedAtUtc fields if necessary. + /// Asynchronously adds a list of documents to the collection. + /// Populates the Id and AddedAtUtc fields if necessary. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -70,8 +70,8 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Asynchronously adds a list of documents to the collection. - /// Populates the Id and AddedAtUtc fields if necessary. + /// Asynchronously adds a list of documents to the collection. + /// Populates the Id and AddedAtUtc fields if necessary. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -82,8 +82,8 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Adds a list of documents to the collection. - /// Populates the Id and AddedAtUtc fields if necessary. + /// Adds a list of documents to the collection. + /// Populates the Id and AddedAtUtc fields if necessary. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -93,8 +93,8 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Adds a list of documents to the collection. - /// Populates the Id and AddedAtUtc fields if necessary. + /// Adds a list of documents to the collection. + /// Populates the Id and AddedAtUtc fields if necessary. /// /// The type representing a Document. /// The type of the primary key for a Document. diff --git a/MongoDbGenericRepository/IBaseMongoRepository.Delete.cs b/MongoDbGenericRepository/IBaseMongoRepository.Delete.cs index 9941b6d..1407d5f 100644 --- a/MongoDbGenericRepository/IBaseMongoRepository.Delete.cs +++ b/MongoDbGenericRepository/IBaseMongoRepository.Delete.cs @@ -296,6 +296,5 @@ namespace MongoDbGenericRepository long DeleteMany(Expression> filter, string partitionKey, CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; - } } \ No newline at end of file diff --git a/MongoDbGenericRepository/IBaseMongoRepository.Index.cs b/MongoDbGenericRepository/IBaseMongoRepository.Index.cs index 84abebf..cccdc08 100644 --- a/MongoDbGenericRepository/IBaseMongoRepository.Index.cs +++ b/MongoDbGenericRepository/IBaseMongoRepository.Index.cs @@ -8,12 +8,12 @@ using MongoDbGenericRepository.Models; namespace MongoDbGenericRepository { /// - /// The interface exposing index management functionality for Guid Keyed repositories. + /// The interface exposing index management functionality for Guid Keyed repositories. /// public interface IBaseMongoRepository_Index : IBaseMongoRepository_Index { /// - /// Returns the names of the indexes present on a collection. + /// Returns the names of the indexes present on a collection. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -23,7 +23,7 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Returns the names of the indexes present on a collection. + /// Returns the names of the indexes present on a collection. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -34,7 +34,7 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Returns the names of the indexes present on a collection. + /// Returns the names of the indexes present on a collection. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -45,7 +45,7 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Returns the names of the indexes present on a collection. + /// Returns the names of the indexes present on a collection. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -57,9 +57,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Create a text index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Create a text index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -70,9 +70,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Create a text index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Create a text index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -84,9 +84,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Create a text index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Create a text index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -98,9 +98,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Create a text index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Create a text index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -113,9 +113,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Create a text index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Create a text index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -127,9 +127,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Create a text index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Create a text index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -137,14 +137,17 @@ namespace MongoDbGenericRepository /// Options for creating an index. /// The cancellation token /// The result of the create index operation. - Task CreateTextIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken) + Task CreateTextIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Create a text index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Create a text index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -152,14 +155,17 @@ namespace MongoDbGenericRepository /// Options for creating an index. /// An optional partition key. /// The result of the create index operation. - Task CreateTextIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey) + Task CreateTextIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey) where TDocument : IDocument where TKey : IEquatable; /// - /// Create a text index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Create a text index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -168,14 +174,18 @@ namespace MongoDbGenericRepository /// An optional partition key. /// The cancellation token. /// The result of the create index operation. - Task CreateTextIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken) + Task CreateTextIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Creates an index on the given field in ascending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in ascending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -186,9 +196,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Creates an index on the given field in ascending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in ascending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -200,9 +210,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Creates an index on the given field in ascending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in ascending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -214,9 +224,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Creates an index on the given field in ascending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in ascending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -224,14 +234,17 @@ namespace MongoDbGenericRepository /// Options for creating an index. /// The cancellation token. /// The result of the create index operation. - Task CreateAscendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken) + Task CreateAscendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Creates an index on the given field in ascending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in ascending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -243,9 +256,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Creates an index on the given field in ascending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in ascending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -253,14 +266,17 @@ namespace MongoDbGenericRepository /// An optional partition key. /// The cancellation token. /// The result of the create index operation. - Task CreateAscendingIndexAsync(Expression> field, string partitionKey, CancellationToken cancellationToken) + Task CreateAscendingIndexAsync( + Expression> field, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Creates an index on the given field in ascending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in ascending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -268,14 +284,17 @@ namespace MongoDbGenericRepository /// Options for creating an index. /// An optional partition key. /// The result of the create index operation. - Task CreateAscendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey) + Task CreateAscendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey) where TDocument : IDocument where TKey : IEquatable; /// - /// Creates an index on the given field in ascending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in ascending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -284,14 +303,18 @@ namespace MongoDbGenericRepository /// An optional partition key. /// The cancellation token. /// The result of the create index operation. - Task CreateAscendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken) + Task CreateAscendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Creates an index on the given field in descending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in descending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -302,9 +325,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Creates an index on the given field in descending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in descending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -316,9 +339,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Creates an index on the given field in descending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in descending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -330,9 +353,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Creates an index on the given field in descending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in descending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -340,14 +363,17 @@ namespace MongoDbGenericRepository /// Options for creating an index. /// The cancellation token. /// The result of the create index operation. - Task CreateDescendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken) + Task CreateDescendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Creates an index on the given field in descending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in descending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -359,9 +385,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Creates an index on the given field in descending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in descending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -369,14 +395,17 @@ namespace MongoDbGenericRepository /// An optional partition key. /// The cancellation token. /// The result of the create index operation. - Task CreateDescendingIndexAsync(Expression> field, string partitionKey, CancellationToken cancellationToken) + Task CreateDescendingIndexAsync( + Expression> field, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Creates an index on the given field in descending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in descending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -384,14 +413,17 @@ namespace MongoDbGenericRepository /// Options for creating an index. /// An optional partition key. /// The result of the create index operation. - Task CreateDescendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey) + Task CreateDescendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey) where TDocument : IDocument where TKey : IEquatable; /// - /// Creates an index on the given field in descending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in descending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -400,14 +432,18 @@ namespace MongoDbGenericRepository /// An optional partition key. /// The cancellation token. /// The result of the create index operation. - Task CreateDescendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken) + Task CreateDescendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Creates a hashed index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a hashed index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -418,9 +454,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Creates a hashed index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a hashed index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -432,9 +468,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Creates a hashed index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a hashed index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -446,9 +482,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Creates a hashed index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a hashed index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -456,14 +492,17 @@ namespace MongoDbGenericRepository /// Options for creating an index. /// The cancellation token. /// The result of the create index operation. - Task CreateHashedIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken) + Task CreateHashedIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Creates a hashed index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a hashed index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -475,9 +514,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Creates a hashed index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a hashed index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -485,14 +524,17 @@ namespace MongoDbGenericRepository /// An optional partition key. /// The cancellation token. /// The result of the create index operation. - Task CreateHashedIndexAsync(Expression> field, string partitionKey, CancellationToken cancellationToken) + Task CreateHashedIndexAsync( + Expression> field, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Creates a hashed index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a hashed index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -500,14 +542,17 @@ namespace MongoDbGenericRepository /// Options for creating an index. /// An optional partition key. /// The result of the create index operation. - Task CreateHashedIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey) + Task CreateHashedIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey) where TDocument : IDocument where TKey : IEquatable; /// - /// Creates a hashed index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a hashed index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -516,14 +561,18 @@ namespace MongoDbGenericRepository /// An optional partition key. /// The cancellation token. /// The result of the create index operation. - Task CreateHashedIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken) + Task CreateHashedIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Creates a combined text index. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a combined text index. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -534,9 +583,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Creates a combined text index. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a combined text index. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -548,23 +597,25 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Creates a combined text index. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a combined text index. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The fields we want to index. /// Options for creating an index. /// The result of the create index operation. - Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions) + Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions) where TDocument : IDocument where TKey : IEquatable; /// - /// Creates a combined text index. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a combined text index. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -572,14 +623,17 @@ namespace MongoDbGenericRepository /// Options for creating an index. /// The cancellation token. /// The result of the create index operation. - Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken) + Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Creates a combined text index. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a combined text index. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -591,9 +645,9 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Creates a combined text index. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a combined text index. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -601,14 +655,17 @@ namespace MongoDbGenericRepository /// An optional partition key. /// The cancellation token. /// The result of the create index operation. - Task CreateCombinedTextIndexAsync(IEnumerable>> fields, string partitionKey, CancellationToken cancellationToken) + Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Creates a combined text index. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a combined text index. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -616,14 +673,17 @@ namespace MongoDbGenericRepository /// Options for creating an index. /// An optional partition key. /// The result of the create index operation. - Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions, string partitionKey) + Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions, + string partitionKey) where TDocument : IDocument where TKey : IEquatable; /// - /// Creates a combined text index. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a combined text index. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -632,12 +692,16 @@ namespace MongoDbGenericRepository /// An optional partition key. /// The cancellation token. /// The result of the create index operation. - Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken) + Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument where TKey : IEquatable; /// - /// Drops the index given a field name + /// Drops the index given a field name /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -647,7 +711,7 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Drops the index given a field name + /// Drops the index given a field name /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -658,7 +722,7 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Drops the index given a field name + /// Drops the index given a field name /// /// The type representing a Document. /// The type of the primary key for a Document. @@ -669,7 +733,7 @@ namespace MongoDbGenericRepository where TKey : IEquatable; /// - /// Drops the index given a field name + /// Drops the index given a field name /// /// The type representing a Document. /// The type of the primary key for a Document. diff --git a/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.Delete.cs b/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.Delete.cs index e2d8f39..5010c08 100644 --- a/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.Delete.cs +++ b/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.Delete.cs @@ -1,10 +1,10 @@ -using MongoDbGenericRepository.DataAccess.Delete; -using MongoDbGenericRepository.Models; -using System; +using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; +using MongoDbGenericRepository.DataAccess.Delete; +using MongoDbGenericRepository.Models; namespace MongoDbGenericRepository { @@ -14,13 +14,16 @@ namespace MongoDbGenericRepository private IMongoDbEraser _mongoDbEraser; /// - /// The MongoDb accessor to delete data. + /// The MongoDb accessor to delete data. /// protected virtual IMongoDbEraser MongoDbEraser { get { - if (_mongoDbEraser != null) { return _mongoDbEraser; } + if (_mongoDbEraser != null) + { + return _mongoDbEraser; + } lock (_initLock) { @@ -29,9 +32,10 @@ namespace MongoDbGenericRepository _mongoDbEraser = new MongoDbEraser(MongoDbContext); } } + return _mongoDbEraser; } - set { _mongoDbEraser = value; } + set => _mongoDbEraser = value; } /// @@ -112,7 +116,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task DeleteOneAsync(Expression> filter, string partitionKey, CancellationToken cancellationToken) + public virtual async Task DeleteOneAsync( + Expression> filter, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbEraser.DeleteOneAsync(filter, partitionKey, cancellationToken); @@ -154,7 +161,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task DeleteManyAsync(Expression> filter, string partitionKey, CancellationToken cancellationToken) + public virtual async Task DeleteManyAsync( + Expression> filter, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbEraser.DeleteManyAsync(filter, partitionKey, cancellationToken); @@ -178,21 +188,21 @@ namespace MongoDbGenericRepository public virtual long DeleteMany(Expression> filter) where TDocument : IDocument { - return DeleteMany(filter, null, CancellationToken.None); + return DeleteMany(filter, null, CancellationToken.None); } /// public virtual long DeleteMany(Expression> filter, CancellationToken cancellationToken) where TDocument : IDocument { - return DeleteMany(filter, null, cancellationToken); + return DeleteMany(filter, null, cancellationToken); } /// public virtual long DeleteMany(Expression> filter, string partitionKey) where TDocument : IDocument { - return DeleteMany(filter, partitionKey, CancellationToken.None); + return DeleteMany(filter, partitionKey, CancellationToken.None); } /// @@ -202,4 +212,4 @@ namespace MongoDbGenericRepository return MongoDbEraser.DeleteMany(filter, partitionKey, cancellationToken); } } -} +} \ No newline at end of file diff --git a/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.Index.cs b/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.Index.cs index a327965..485d899 100644 --- a/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.Index.cs +++ b/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.Index.cs @@ -298,14 +298,19 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateHashedIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions) + public virtual async Task CreateHashedIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions) where TDocument : IDocument { return await CreateHashedIndexAsync(field, indexCreationOptions, null, CancellationToken.None); } /// - public virtual async Task CreateHashedIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken) + public virtual async Task CreateHashedIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + CancellationToken cancellationToken) where TDocument : IDocument { return await CreateHashedIndexAsync(field, indexCreationOptions, null, cancellationToken); @@ -319,21 +324,31 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateHashedIndexAsync(Expression> field, string partitionKey, CancellationToken cancellationToken) + public virtual async Task CreateHashedIndexAsync( + Expression> field, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await CreateHashedIndexAsync(field, null, partitionKey, cancellationToken); } /// - public virtual async Task CreateHashedIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey) + public virtual async Task CreateHashedIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey) where TDocument : IDocument { return await CreateHashedIndexAsync(field, indexCreationOptions, partitionKey, CancellationToken.None); } /// - public virtual async Task CreateHashedIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken) + public virtual async Task CreateHashedIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbIndexHandler.CreateHashedIndexAsync(field, indexCreationOptions, partitionKey, cancellationToken); @@ -347,21 +362,28 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, CancellationToken cancellationToken) + public virtual async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + CancellationToken cancellationToken) where TDocument : IDocument { return await CreateCombinedTextIndexAsync(fields, null, null, cancellationToken); } /// - public virtual async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions) + public virtual async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions) where TDocument : IDocument { return await CreateCombinedTextIndexAsync(fields, indexCreationOptions, null, CancellationToken.None); } /// - public virtual async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken) + public virtual async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions, + CancellationToken cancellationToken) where TDocument : IDocument { return await CreateCombinedTextIndexAsync(fields, indexCreationOptions, null, cancellationToken); @@ -375,21 +397,31 @@ namespace MongoDbGenericRepository } /// - public virtual async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, string partitionKey, CancellationToken cancellationToken) + public virtual async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await CreateCombinedTextIndexAsync(fields, null, partitionKey, cancellationToken); } /// - public virtual async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions, string partitionKey) + public virtual async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions, + string partitionKey) where TDocument : IDocument { return await CreateCombinedTextIndexAsync(fields, indexCreationOptions, partitionKey, CancellationToken.None); } /// - public virtual async Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken) + public virtual async Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbIndexHandler.CreateCombinedTextIndexAsync(fields, indexCreationOptions, partitionKey, cancellationToken); diff --git a/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.Main.cs b/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.Main.cs index eeca6ab..12b41fa 100644 --- a/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.Main.cs +++ b/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.Main.cs @@ -1,24 +1,23 @@ -using MongoDB.Driver; +using System; +using MongoDB.Driver; using MongoDbGenericRepository.Models; -using System; namespace MongoDbGenericRepository { /// - /// The base Repository, it is meant to be inherited from by your custom custom MongoRepository implementation. - /// Its constructor must be given a connection string and a database name. + /// The base Repository, it is meant to be inherited from by your custom custom MongoRepository implementation. + /// Its constructor must be given a connection string and a database name. /// /// The type of the document Id. - public abstract partial class BaseMongoRepository : - ReadOnlyMongoRepository, + public abstract partial class BaseMongoRepository : + ReadOnlyMongoRepository, IBaseMongoRepository where TKey : IEquatable { - private readonly object _initLock = new object(); /// - /// The constructor taking a connection string and a database name. + /// The constructor taking a connection string and a database name. /// /// The connection string of the MongoDb server. /// The name of the database against which you want to perform operations. @@ -27,23 +26,23 @@ namespace MongoDbGenericRepository } /// - /// The constructor taking a . + /// The constructor taking a . /// - /// A mongodb context implementing + /// A mongodb context implementing protected BaseMongoRepository(IMongoDbContext mongoDbContext) : base(mongoDbContext) { } /// - /// The constructor taking a . + /// The constructor taking a . /// - /// A mongodb context implementing + /// A mongodb context implementing protected BaseMongoRepository(IMongoDatabase mongoDatabase) : base(mongoDatabase) { } /// - /// Gets a collections for a potentially partitioned document type. + /// Gets a collections for a potentially partitioned document type. /// /// The document type. /// The collection partition key. @@ -55,11 +54,12 @@ namespace MongoDbGenericRepository { return GetCollection(partitionKey); } + return GetCollection(); } /// - /// Gets a collections for the type TDocument with a partition key. + /// Gets a collections for the type TDocument with a partition key. /// /// The document type. /// The collection partition key. @@ -70,4 +70,4 @@ namespace MongoDbGenericRepository return MongoDbContext.GetCollection(partitionKey); } } -} +} \ No newline at end of file diff --git a/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.ReadOnly.cs b/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.ReadOnly.cs index 4e5c741..2c670c5 100644 --- a/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.ReadOnly.cs +++ b/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.ReadOnly.cs @@ -17,16 +17,6 @@ namespace MongoDbGenericRepository public abstract class ReadOnlyMongoRepository : IReadOnlyMongoRepository where TKey : IEquatable { - /// - /// The MongoDbContext - /// - protected IMongoDbContext MongoDbContext { get; set; } - - /// - /// A MongoDb Reader for read operations - /// - protected IMongoDbReader MongoDbReader { get; set; } - /// /// The constructor taking a connection string and a database name. /// @@ -55,6 +45,16 @@ namespace MongoDbGenericRepository SetupMongoDbContext(mongoDbContext); } + /// + /// The MongoDbContext + /// + protected IMongoDbContext MongoDbContext { get; set; } + + /// + /// A MongoDb Reader for read operations + /// + protected IMongoDbReader MongoDbReader { get; set; } + /// /// The connection string. /// diff --git a/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.Update.cs b/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.Update.cs index 3d66778..1dd1870 100644 --- a/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.Update.cs +++ b/MongoDbGenericRepository/KeyTypedRepository/BaseMongoRepository.TKey.Update.cs @@ -1,10 +1,10 @@ -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 { @@ -14,13 +14,16 @@ namespace MongoDbGenericRepository private IMongoDbUpdater _mongoDbUpdater; /// - /// The MongoDb accessor to update data. + /// The MongoDb accessor to update data. /// protected virtual IMongoDbUpdater MongoDbUpdater { get { - if (_mongoDbUpdater != null) { return _mongoDbUpdater; } + if (_mongoDbUpdater != null) + { + return _mongoDbUpdater; + } lock (_initLock) { @@ -32,7 +35,7 @@ namespace MongoDbGenericRepository return _mongoDbUpdater; } - set { _mongoDbUpdater = value; } + set => _mongoDbUpdater = value; } /// @@ -71,7 +74,10 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateOneAsync(TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken) + public virtual async Task UpdateOneAsync( + TDocument documentToModify, + UpdateDefinition update, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbUpdater.UpdateOneAsync(documentToModify, update, cancellationToken); @@ -99,7 +105,11 @@ namespace MongoDbGenericRepository } /// - public virtual bool UpdateOne(TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken) + public virtual bool UpdateOne( + TDocument documentToModify, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return MongoDbUpdater.UpdateOne(documentToModify, field, value, cancellationToken); @@ -113,7 +123,11 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateOneAsync(TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken) + public virtual async Task UpdateOneAsync( + TDocument documentToModify, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbUpdater.UpdateOneAsync(documentToModify, field, value, cancellationToken); @@ -127,21 +141,34 @@ namespace MongoDbGenericRepository } /// - public virtual bool UpdateOne(FilterDefinition filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual bool UpdateOne( + FilterDefinition filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return UpdateOne(filter, field, value, null, cancellationToken); } /// - public virtual bool UpdateOne(FilterDefinition filter, Expression> field, TField value, string partitionKey) + public virtual bool UpdateOne( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument { return UpdateOne(filter, field, value, partitionKey, CancellationToken.None); } /// - public virtual bool UpdateOne(FilterDefinition filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual bool UpdateOne( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return MongoDbUpdater.UpdateOne(filter, field, value, partitionKey, cancellationToken); @@ -155,133 +182,210 @@ namespace MongoDbGenericRepository } /// - public virtual bool UpdateOne(Expression> filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual bool UpdateOne( + Expression> filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return UpdateOne(filter, field, value, null, cancellationToken); } /// - public virtual bool UpdateOne(Expression> filter, Expression> field, TField value, string partitionKey) + public virtual bool UpdateOne( + Expression> filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument { return UpdateOne(filter, field, value, partitionKey, CancellationToken.None); } /// - public virtual bool UpdateOne(Expression> filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual bool UpdateOne( + Expression> filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return MongoDbUpdater.UpdateOne(filter, field, value, partitionKey, cancellationToken); } /// - public virtual async Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value) + public virtual async Task UpdateOneAsync( + FilterDefinition filter, + Expression> field, + TField value) where TDocument : IDocument { return await UpdateOneAsync(filter, field, value, null, CancellationToken.None); } /// - public virtual async Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual async Task UpdateOneAsync( + FilterDefinition filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return await UpdateOneAsync(filter, field, value, null, cancellationToken); } /// - public virtual async Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey) + public virtual async Task UpdateOneAsync( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument { return await UpdateOneAsync(filter, field, value, partitionKey, CancellationToken.None); } /// - public virtual async Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual async Task UpdateOneAsync( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbUpdater.UpdateOneAsync(filter, field, value, partitionKey, cancellationToken); } /// - public virtual async Task UpdateOneAsync(Expression> filter, Expression> field, TField value) + public virtual async Task UpdateOneAsync( + Expression> filter, + Expression> field, + TField value) where TDocument : IDocument { return await UpdateOneAsync(filter, field, value, null, CancellationToken.None); } /// - public virtual async Task UpdateOneAsync(Expression> filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual async Task UpdateOneAsync( + Expression> filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return await UpdateOneAsync(filter, field, value, null, cancellationToken); } /// - public virtual async Task UpdateOneAsync(Expression> filter, Expression> field, TField value, string partitionKey) + public virtual async Task UpdateOneAsync( + Expression> filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument { return await UpdateOneAsync(filter, field, value, partitionKey, CancellationToken.None); } /// - public virtual async Task UpdateOneAsync(Expression> filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual async Task UpdateOneAsync( + Expression> filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbUpdater.UpdateOneAsync(filter, field, value, partitionKey, cancellationToken); } /// - public virtual async Task UpdateManyAsync(Expression> filter, Expression> field, TField value) + public virtual async Task UpdateManyAsync( + Expression> filter, + Expression> field, + TField value) where TDocument : IDocument { return await UpdateManyAsync(filter, field, value, null, CancellationToken.None); } /// - public virtual async Task UpdateManyAsync(Expression> filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + Expression> filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return await UpdateManyAsync(filter, field, value, null, cancellationToken); } /// - public virtual async Task UpdateManyAsync(Expression> filter, Expression> field, TField value, string partitionKey) + public virtual async Task UpdateManyAsync( + Expression> filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument { return await UpdateManyAsync(filter, field, value, partitionKey, CancellationToken.None); } /// - public virtual async Task UpdateManyAsync(Expression> filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + Expression> filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbUpdater.UpdateManyAsync(filter, field, value, partitionKey, cancellationToken); } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + Expression> field, + TField value) where TDocument : IDocument { return await UpdateManyAsync(filter, field, value, null, CancellationToken.None); } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return await UpdateManyAsync(filter, field, value, null, cancellationToken); } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument { return await UpdateManyAsync(filter, field, value, partitionKey, CancellationToken.None); } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbUpdater.UpdateManyAsync(filter, field, value, partitionKey, cancellationToken); @@ -295,21 +399,31 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, UpdateDefinition updateDefinition, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + UpdateDefinition updateDefinition, + CancellationToken cancellationToken) where TDocument : IDocument { return await UpdateManyAsync(filter, updateDefinition, null, cancellationToken); } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + UpdateDefinition updateDefinition, + string partitionKey) where TDocument : IDocument { return await UpdateManyAsync(filter, updateDefinition, partitionKey, CancellationToken.None); } /// - public virtual async Task UpdateManyAsync(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + FilterDefinition filter, + UpdateDefinition updateDefinition, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbUpdater.UpdateManyAsync(filter, updateDefinition, partitionKey, cancellationToken); @@ -323,21 +437,31 @@ namespace MongoDbGenericRepository } /// - public virtual async Task UpdateManyAsync(Expression> filter, UpdateDefinition updateDefinition, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + Expression> filter, + UpdateDefinition updateDefinition, + CancellationToken cancellationToken) where TDocument : IDocument { return await UpdateManyAsync(filter, updateDefinition, null, cancellationToken); } /// - public virtual async Task UpdateManyAsync(Expression> filter, UpdateDefinition updateDefinition, string partitionKey) + public virtual async Task UpdateManyAsync( + Expression> filter, + UpdateDefinition updateDefinition, + string partitionKey) where TDocument : IDocument { return await UpdateManyAsync(filter, updateDefinition, partitionKey, CancellationToken.None); } /// - public virtual async Task UpdateManyAsync(Expression> filter, UpdateDefinition updateDefinition, string partitionKey, CancellationToken cancellationToken) + public virtual async Task UpdateManyAsync( + Expression> filter, + UpdateDefinition updateDefinition, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return await MongoDbUpdater.UpdateManyAsync(filter, updateDefinition, partitionKey, cancellationToken); @@ -351,21 +475,34 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(Expression> filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual long UpdateMany( + Expression> filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return UpdateMany(filter, field, value, null, cancellationToken); } /// - public virtual long UpdateMany(Expression> filter, Expression> field, TField value, string partitionKey) + public virtual long UpdateMany( + Expression> filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument { return UpdateMany(filter, field, value, partitionKey, CancellationToken.None); } /// - public virtual long UpdateMany(Expression> filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual long UpdateMany( + Expression> filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return MongoDbUpdater.UpdateMany(filter, field, value, partitionKey, cancellationToken); @@ -379,21 +516,34 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(FilterDefinition filter, Expression> field, TField value, CancellationToken cancellationToken) + public virtual long UpdateMany( + FilterDefinition filter, + Expression> field, + TField value, + CancellationToken cancellationToken) where TDocument : IDocument { return MongoDbUpdater.UpdateMany(filter, field, value, null, cancellationToken); } /// - public virtual long UpdateMany(FilterDefinition filter, Expression> field, TField value, string partitionKey) + public virtual long UpdateMany( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey) where TDocument : IDocument { return MongoDbUpdater.UpdateMany(filter, field, value, partitionKey, CancellationToken.None); } /// - public virtual long UpdateMany(FilterDefinition filter, Expression> field, TField value, string partitionKey, CancellationToken cancellationToken) + public virtual long UpdateMany( + FilterDefinition filter, + Expression> field, + TField value, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return MongoDbUpdater.UpdateMany(filter, field, value, partitionKey, cancellationToken); @@ -407,7 +557,10 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(FilterDefinition filter, UpdateDefinition updateDefinition, CancellationToken cancellationToken) + public virtual long UpdateMany( + FilterDefinition filter, + UpdateDefinition updateDefinition, + CancellationToken cancellationToken) where TDocument : IDocument { return UpdateMany(filter, updateDefinition, null, cancellationToken); @@ -421,7 +574,11 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey, CancellationToken cancellationToken) + public virtual long UpdateMany( + FilterDefinition filter, + UpdateDefinition updateDefinition, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return MongoDbUpdater.UpdateMany(filter, updateDefinition, partitionKey, cancellationToken); @@ -435,7 +592,10 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(Expression> filter, UpdateDefinition updateDefinition, CancellationToken cancellationToken) + public virtual long UpdateMany( + Expression> filter, + UpdateDefinition updateDefinition, + CancellationToken cancellationToken) where TDocument : IDocument { return UpdateMany(filter, updateDefinition, null, cancellationToken); @@ -449,7 +609,11 @@ namespace MongoDbGenericRepository } /// - public virtual long UpdateMany(Expression> filter, UpdateDefinition updateDefinition, string partitionKey, CancellationToken cancellationToken) + public virtual long UpdateMany( + Expression> filter, + UpdateDefinition updateDefinition, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument { return MongoDbUpdater.UpdateMany(filter, updateDefinition, partitionKey, cancellationToken); diff --git a/MongoDbGenericRepository/KeyTypedRepository/IBaseMongoRepository.TKey.Delete.cs b/MongoDbGenericRepository/KeyTypedRepository/IBaseMongoRepository.TKey.Delete.cs index 883d7c9..32d269d 100644 --- a/MongoDbGenericRepository/KeyTypedRepository/IBaseMongoRepository.TKey.Delete.cs +++ b/MongoDbGenericRepository/KeyTypedRepository/IBaseMongoRepository.TKey.Delete.cs @@ -8,14 +8,14 @@ using MongoDbGenericRepository.Models; namespace MongoDbGenericRepository { /// - /// The interface exposing deletion functionality for Key typed repositories. + /// The interface exposing deletion functionality for Key typed repositories. /// /// The type of the document Id. public interface IBaseMongoRepository_Delete where TKey : IEquatable { /// - /// Deletes a document. + /// Deletes a document. /// /// The type representing a Document. /// The document you want to delete. @@ -24,7 +24,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Deletes a document. + /// Deletes a document. /// /// The type representing a Document. /// The document you want to delete. @@ -34,7 +34,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Deletes a document matching the condition of the LINQ expression filter. + /// Deletes a document matching the condition of the LINQ expression filter. /// /// The type representing a Document. /// A LINQ expression filter. @@ -43,7 +43,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Deletes a document matching the condition of the LINQ expression filter. + /// Deletes a document matching the condition of the LINQ expression filter. /// /// The type representing a Document. /// A LINQ expression filter. @@ -53,7 +53,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Deletes a document matching the condition of the LINQ expression filter. + /// Deletes a document matching the condition of the LINQ expression filter. /// /// The type representing a Document. /// A LINQ expression filter. @@ -63,7 +63,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Deletes a document matching the condition of the LINQ expression filter. + /// Deletes a document matching the condition of the LINQ expression filter. /// /// The type representing a Document. /// A LINQ expression filter. @@ -74,7 +74,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Asynchronously deletes a document matching the condition of the LINQ expression filter. + /// Asynchronously deletes a document matching the condition of the LINQ expression filter. /// /// The type representing a Document. /// The document you want to delete. @@ -83,7 +83,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Asynchronously deletes a document matching the condition of the LINQ expression filter. + /// Asynchronously deletes a document matching the condition of the LINQ expression filter. /// /// The type representing a Document. /// The document you want to delete. @@ -94,7 +94,7 @@ namespace MongoDbGenericRepository /// - /// Asynchronously deletes a document matching the condition of the LINQ expression filter. + /// Asynchronously deletes a document matching the condition of the LINQ expression filter. /// /// The type representing a Document. /// A LINQ expression filter. @@ -103,7 +103,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Asynchronously deletes a document matching the condition of the LINQ expression filter. + /// Asynchronously deletes a document matching the condition of the LINQ expression filter. /// /// The type representing a Document. /// A LINQ expression filter. @@ -113,7 +113,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Asynchronously deletes a document matching the condition of the LINQ expression filter. + /// Asynchronously deletes a document matching the condition of the LINQ expression filter. /// /// The type representing a Document. /// A LINQ expression filter. @@ -123,7 +123,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Asynchronously deletes a document matching the condition of the LINQ expression filter. + /// Asynchronously deletes a document matching the condition of the LINQ expression filter. /// /// The type representing a Document. /// A LINQ expression filter. @@ -134,7 +134,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Asynchronously deletes the documents matching the condition of the LINQ expression filter. + /// Asynchronously deletes the documents matching the condition of the LINQ expression filter. /// /// The type representing a Document. /// A LINQ expression filter. @@ -143,7 +143,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Asynchronously deletes the documents matching the condition of the LINQ expression filter. + /// Asynchronously deletes the documents matching the condition of the LINQ expression filter. /// /// The type representing a Document. /// A LINQ expression filter. @@ -153,7 +153,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Asynchronously deletes the documents matching the condition of the LINQ expression filter. + /// Asynchronously deletes the documents matching the condition of the LINQ expression filter. /// /// The type representing a Document. /// A LINQ expression filter. @@ -163,7 +163,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Asynchronously deletes the documents matching the condition of the LINQ expression filter. + /// Asynchronously deletes the documents matching the condition of the LINQ expression filter. /// /// The type representing a Document. /// A LINQ expression filter. @@ -174,7 +174,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Asynchronously deletes a list of documents. + /// Asynchronously deletes a list of documents. /// /// The type representing a Document. /// The list of documents to delete. @@ -183,7 +183,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Asynchronously deletes a list of documents. + /// Asynchronously deletes a list of documents. /// /// The type representing a Document. /// The list of documents to delete. @@ -193,7 +193,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Deletes a list of documents. + /// Deletes a list of documents. /// /// The type representing a Document. /// The list of documents to delete. @@ -202,7 +202,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Deletes a list of documents. + /// Deletes a list of documents. /// /// The type representing a Document. /// The list of documents to delete. @@ -212,7 +212,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Deletes the documents matching the condition of the LINQ expression filter. + /// Deletes the documents matching the condition of the LINQ expression filter. /// /// The type representing a Document. /// A LINQ expression filter. @@ -221,7 +221,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Deletes the documents matching the condition of the LINQ expression filter. + /// Deletes the documents matching the condition of the LINQ expression filter. /// /// The type representing a Document. /// A LINQ expression filter. @@ -231,7 +231,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Deletes the documents matching the condition of the LINQ expression filter. + /// Deletes the documents matching the condition of the LINQ expression filter. /// /// The type representing a Document. /// A LINQ expression filter. @@ -241,7 +241,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Deletes the documents matching the condition of the LINQ expression filter. + /// Deletes the documents matching the condition of the LINQ expression filter. /// /// The type representing a Document. /// A LINQ expression filter. diff --git a/MongoDbGenericRepository/KeyTypedRepository/IBaseMongoRepository.TKey.Index.cs b/MongoDbGenericRepository/KeyTypedRepository/IBaseMongoRepository.TKey.Index.cs index cce8c25..f82e6fa 100644 --- a/MongoDbGenericRepository/KeyTypedRepository/IBaseMongoRepository.TKey.Index.cs +++ b/MongoDbGenericRepository/KeyTypedRepository/IBaseMongoRepository.TKey.Index.cs @@ -8,13 +8,14 @@ using MongoDbGenericRepository.Models; namespace MongoDbGenericRepository { /// - /// The interface exposing index management functionality for Key typed repositories. + /// The interface exposing index management functionality for Key typed repositories. /// /// - public interface IBaseMongoRepository_Index where TKey : IEquatable + public interface IBaseMongoRepository_Index + where TKey : IEquatable { /// - /// Returns the names of the indexes present on a collection. + /// Returns the names of the indexes present on a collection. /// /// The type representing a Document. /// A list containing the names of the indexes on on the concerned collection. @@ -22,7 +23,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Returns the names of the indexes present on a collection. + /// Returns the names of the indexes present on a collection. /// /// The type representing a Document. /// The cancellation token. @@ -31,7 +32,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Returns the names of the indexes present on a collection. + /// Returns the names of the indexes present on a collection. /// /// The type representing a Document. /// An optional partition key @@ -40,7 +41,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Returns the names of the indexes present on a collection. + /// Returns the names of the indexes present on a collection. /// /// The type representing a Document. /// An optional partition key @@ -50,9 +51,9 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Create a text index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Create a text index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -61,9 +62,9 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Create a text index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Create a text index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -73,9 +74,9 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Create a text index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Create a text index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -85,22 +86,25 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Create a text index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Create a text index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. /// Options for creating an index. /// The cancellation token. /// The result of the create index operation. - Task CreateTextIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken) + Task CreateTextIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + CancellationToken cancellationToken) where TDocument : IDocument; /// - /// Create a text index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Create a text index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -110,9 +114,9 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Create a text index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Create a text index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -123,9 +127,9 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Create a text index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Create a text index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -136,9 +140,9 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Create a text index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Create a text index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -146,14 +150,18 @@ namespace MongoDbGenericRepository /// An optional partition key. /// The cancellation token. /// The result of the create index operation. - Task CreateTextIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken) + Task CreateTextIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument; /// - /// Creates an index on the given field in ascending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in ascending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -162,9 +170,9 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates an index on the given field in ascending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in ascending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -174,9 +182,9 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates an index on the given field in ascending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in ascending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -186,22 +194,25 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates an index on the given field in ascending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in ascending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. /// Options for creating an index. /// The cancellation token. /// The result of the create index operation. - Task CreateAscendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken) + Task CreateAscendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + CancellationToken cancellationToken) where TDocument : IDocument; /// - /// Creates an index on the given field in ascending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in ascending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -211,9 +222,9 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates an index on the given field in ascending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in ascending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -224,22 +235,25 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates an index on the given field in ascending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in ascending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. /// Options for creating an index. /// An optional partition key. /// The result of the create index operation. - Task CreateAscendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey) + Task CreateAscendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey) where TDocument : IDocument; /// - /// Creates an index on the given field in ascending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in ascending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -247,13 +261,17 @@ namespace MongoDbGenericRepository /// An optional partition key. /// The cancellation token. /// The result of the create index operation. - Task CreateAscendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken) + Task CreateAscendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument; /// - /// Creates an index on the given field in descending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in descending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -262,9 +280,9 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates an index on the given field in descending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in descending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -274,9 +292,9 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates an index on the given field in descending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in descending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -286,22 +304,25 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates an index on the given field in descending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in descending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. /// Options for creating an index. /// The cancellation token. /// The result of the create index operation. - Task CreateDescendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken) + Task CreateDescendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + CancellationToken cancellationToken) where TDocument : IDocument; /// - /// Creates an index on the given field in descending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in descending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -311,9 +332,9 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates an index on the given field in descending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in descending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -324,22 +345,25 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates an index on the given field in descending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in descending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. /// Options for creating an index. /// An optional partition key. /// The result of the create index operation. - Task CreateDescendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey) + Task CreateDescendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey) where TDocument : IDocument; /// - /// Creates an index on the given field in descending order. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates an index on the given field in descending order. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -347,13 +371,17 @@ namespace MongoDbGenericRepository /// An optional partition key. /// The cancellation token. /// The result of the create index operation. - Task CreateDescendingIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken) + Task CreateDescendingIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument; /// - /// Creates a hashed index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a hashed index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -362,9 +390,9 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates a hashed index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a hashed index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -374,9 +402,9 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates a hashed index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a hashed index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -386,22 +414,25 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates a hashed index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a hashed index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. /// Options for creating an index. /// The cancellation token. /// The result of the create index operation. - Task CreateHashedIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken) + Task CreateHashedIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + CancellationToken cancellationToken) where TDocument : IDocument; /// - /// Creates a hashed index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a hashed index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -411,9 +442,9 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates a hashed index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a hashed index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -424,22 +455,25 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates a hashed index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a hashed index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. /// Options for creating an index. /// An optional partition key. /// The result of the create index operation. - Task CreateHashedIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey) + Task CreateHashedIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey) where TDocument : IDocument; /// - /// Creates a hashed index on the given field. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a hashed index on the given field. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The field we want to index. @@ -447,13 +481,17 @@ namespace MongoDbGenericRepository /// An optional partition key. /// The cancellation token. /// The result of the create index operation. - Task CreateHashedIndexAsync(Expression> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken) + Task CreateHashedIndexAsync( + Expression> field, + IndexCreationOptions indexCreationOptions, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument; /// - /// Creates a combined text index. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a combined text index. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The fields we want to index. @@ -462,9 +500,9 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates a combined text index. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a combined text index. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The fields we want to index. @@ -474,9 +512,9 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates a combined text index. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a combined text index. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The fields we want to index. @@ -486,22 +524,25 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates a combined text index. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a combined text index. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The fields we want to index. /// Options for creating an index. /// The cancellation token. /// The result of the create index operation. - Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken) + Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions, + CancellationToken cancellationToken) where TDocument : IDocument; /// - /// Creates a combined text index. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a combined text index. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The fields we want to index. @@ -511,35 +552,41 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Creates a combined text index. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a combined text index. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The fields we want to index. /// An optional partition key. /// The cancellation token. /// The result of the create index operation. - Task CreateCombinedTextIndexAsync(IEnumerable>> fields, string partitionKey, CancellationToken cancellationToken) + Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument; /// - /// Creates a combined text index. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a combined text index. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The fields we want to index. /// Options for creating an index. /// An optional partition key. /// The result of the create index operation. - Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions, string partitionKey) + Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions, + string partitionKey) where TDocument : IDocument; /// - /// Creates a combined text index. - /// IndexCreationOptions can be supplied to further specify - /// how the creation should be done. + /// Creates a combined text index. + /// IndexCreationOptions can be supplied to further specify + /// how the creation should be done. /// /// The type representing a Document. /// The fields we want to index. @@ -547,11 +594,15 @@ namespace MongoDbGenericRepository /// An optional partition key. /// The cancellation token. /// The result of the create index operation. - Task CreateCombinedTextIndexAsync(IEnumerable>> fields, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken) + Task CreateCombinedTextIndexAsync( + IEnumerable>> fields, + IndexCreationOptions indexCreationOptions, + string partitionKey, + CancellationToken cancellationToken) where TDocument : IDocument; /// - /// Drops the index given a field name + /// Drops the index given a field name /// /// The type representing a Document. /// The name of the index @@ -559,7 +610,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Drops the index given a field name + /// Drops the index given a field name /// /// The type representing a Document. /// The name of the index @@ -568,7 +619,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Drops the index given a field name + /// Drops the index given a field name /// /// The type representing a Document. /// The name of the index @@ -577,7 +628,7 @@ namespace MongoDbGenericRepository where TDocument : IDocument; /// - /// Drops the index given a field name + /// Drops the index given a field name /// /// The type representing a Document. /// The name of the index