Adding TKey support
This commit is contained in:
1 parent
5e187e0b1f
commit
9b1048e318
5 files changed
+417
-78
No files matched your search
@@ -27,7 +27,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously adds a document to the collection.
|
/// Asynchronously adds a document to the collection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="document">The document you want to add.</param>
|
/// <param name="document">The document you want to add.</param>
|
||||||
Task AddOneAsync<TDocument>(TDocument document) where TDocument : IDocument;
|
Task AddOneAsync<TDocument>(TDocument document) where TDocument : IDocument;
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// Adds a document to the collection.
|
/// Adds a document to the collection.
|
||||||
/// Populates the Id and AddedAtUtc fields if necessary.
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="document">The document you want to add.</param>
|
/// <param name="document">The document you want to add.</param>
|
||||||
void AddOne<TDocument>(TDocument document) where TDocument : IDocument;
|
void AddOne<TDocument>(TDocument document) where TDocument : IDocument;
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// Asynchronously adds a list of documents to the collection.
|
/// Asynchronously adds a list of documents to the collection.
|
||||||
/// Populates the Id and AddedAtUtc fields if necessary.
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="documents">The document you want to add.</param>
|
/// <param name="documents">The document you want to add.</param>
|
||||||
Task AddManyAsync<TDocument>(IEnumerable<TDocument> documents) where TDocument : IDocument;
|
Task AddManyAsync<TDocument>(IEnumerable<TDocument> documents) where TDocument : IDocument;
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// Adds a list of documents to the collection.
|
/// Adds a list of documents to the collection.
|
||||||
/// Populates the Id and AddedAtUtc fields if necessary.
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="documents">The document you want to add.</param>
|
/// <param name="documents">The document you want to add.</param>
|
||||||
void AddMany<TDocument>(IEnumerable<TDocument> documents) where TDocument : IDocument;
|
void AddMany<TDocument>(IEnumerable<TDocument> documents) where TDocument : IDocument;
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously returns one document given its id.
|
/// Asynchronously returns one document given its id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="id">The Id of the document you want to get.</param>
|
/// <param name="id">The Id of the document you want to get.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
Task<TDocument> GetByIdAsync<TDocument>(Guid id, string partitionKey = null) where TDocument : IDocument;
|
Task<TDocument> GetByIdAsync<TDocument>(Guid id, string partitionKey = null) where TDocument : IDocument;
|
||||||
@@ -70,7 +70,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns one document given its id.
|
/// Returns one document given its id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="id">The Id of the document you want to get.</param>
|
/// <param name="id">The Id of the document you want to get.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
TDocument GetById<TDocument>(Guid id, string partitionKey = null) where TDocument : IDocument;
|
TDocument GetById<TDocument>(Guid id, string partitionKey = null) where TDocument : IDocument;
|
||||||
@@ -78,7 +78,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously returns one document given an expression filter.
|
/// Asynchronously returns one document given an expression filter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
Task<TDocument> GetOneAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
Task<TDocument> GetOneAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
||||||
@@ -86,7 +86,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns one document given an expression filter.
|
/// Returns one document given an expression filter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
TDocument GetOne<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
TDocument GetOne<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
||||||
@@ -94,7 +94,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a collection cursor.
|
/// Returns a collection cursor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
IFindFluent<TDocument, TDocument> GetCursor<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
IFindFluent<TDocument, TDocument> GetCursor<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
||||||
@@ -102,7 +102,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously returns true if any of the document of the collection matches the filter condition.
|
/// Asynchronously returns true if any of the document of the collection matches the filter condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
Task<bool> AnyAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
Task<bool> AnyAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
||||||
@@ -110,7 +110,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
bool Any<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
bool Any<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
||||||
@@ -118,7 +118,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously returns a list of the documents matching the filter condition.
|
/// Asynchronously returns a list of the documents matching the filter condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
Task<List<TDocument>> GetAllAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
Task<List<TDocument>> GetAllAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
||||||
@@ -126,7 +126,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a list of the documents matching the filter condition.
|
/// Returns a list of the documents matching the filter condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
List<TDocument> GetAll<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
List<TDocument> GetAll<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
||||||
@@ -134,7 +134,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously counts how many documents match the filter condition.
|
/// Asynchronously counts how many documents match the filter condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
Task<long> CountAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
Task<long> CountAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
||||||
@@ -142,7 +142,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Counts how many documents match the filter condition.
|
/// Counts how many documents match the filter condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
long Count<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
long Count<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
||||||
@@ -154,14 +154,14 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously Updates a document.
|
/// Asynchronously Updates a document.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
|
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
|
||||||
Task<bool> UpdateOneAsync<TDocument>(TDocument modifiedDocument) where TDocument : IDocument;
|
Task<bool> UpdateOneAsync<TDocument>(TDocument modifiedDocument) where TDocument : IDocument;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates a document.
|
/// Updates a document.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
|
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
|
||||||
bool UpdateOne<TDocument>(TDocument modifiedDocument) where TDocument : IDocument;
|
bool UpdateOne<TDocument>(TDocument modifiedDocument) where TDocument : IDocument;
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously deletes a document.
|
/// Asynchronously deletes a document.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="document">The document you want to delete.</param>
|
/// <param name="document">The document you want to delete.</param>
|
||||||
/// <returns>The number of documents deleted.</returns>
|
/// <returns>The number of documents deleted.</returns>
|
||||||
Task<long> DeleteOneAsync<TDocument>(TDocument document) where TDocument : IDocument;
|
Task<long> DeleteOneAsync<TDocument>(TDocument document) where TDocument : IDocument;
|
||||||
@@ -180,7 +180,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously deletes a document matching the condition of the LINQ expression filter.
|
/// Asynchronously deletes a document matching the condition of the LINQ expression filter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
/// <returns>The number of documents deleted.</returns>
|
/// <returns>The number of documents deleted.</returns>
|
||||||
@@ -189,7 +189,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes a document.
|
/// Deletes a document.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="document">The document you want to delete.</param>
|
/// <param name="document">The document you want to delete.</param>
|
||||||
/// <returns>The number of documents deleted.</returns>
|
/// <returns>The number of documents deleted.</returns>
|
||||||
long DeleteOne<TDocument>(TDocument document) where TDocument : IDocument;
|
long DeleteOne<TDocument>(TDocument document) where TDocument : IDocument;
|
||||||
@@ -197,7 +197,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes a document matching the condition of the LINQ expression filter.
|
/// Deletes a document matching the condition of the LINQ expression filter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
/// <returns>The number of documents deleted.</returns>
|
/// <returns>The number of documents deleted.</returns>
|
||||||
@@ -206,7 +206,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously deletes the documents matching the condition of the LINQ expression filter.
|
/// Asynchronously deletes the documents matching the condition of the LINQ expression filter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
/// <returns>The number of documents deleted.</returns>
|
/// <returns>The number of documents deleted.</returns>
|
||||||
@@ -215,7 +215,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously deletes a list of documents.
|
/// Asynchronously deletes a list of documents.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="documents">The list of documents to delete.</param>
|
/// <param name="documents">The list of documents to delete.</param>
|
||||||
/// <returns>The number of documents deleted.</returns>
|
/// <returns>The number of documents deleted.</returns>
|
||||||
Task<long> DeleteManyAsync<TDocument>(IEnumerable<TDocument> documents) where TDocument : IDocument;
|
Task<long> DeleteManyAsync<TDocument>(IEnumerable<TDocument> documents) where TDocument : IDocument;
|
||||||
@@ -223,7 +223,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes a list of documents.
|
/// Deletes a list of documents.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="documents">The list of documents to delete.</param>
|
/// <param name="documents">The list of documents to delete.</param>
|
||||||
/// <returns>The number of documents deleted.</returns>
|
/// <returns>The number of documents deleted.</returns>
|
||||||
long DeleteMany<TDocument>(IEnumerable<TDocument> documents) where TDocument : IDocument;
|
long DeleteMany<TDocument>(IEnumerable<TDocument> documents) where TDocument : IDocument;
|
||||||
@@ -231,21 +231,33 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes the documents matching the condition of the LINQ expression filter.
|
/// Deletes the documents matching the condition of the LINQ expression filter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
/// <returns>The number of documents deleted.</returns>
|
/// <returns>The number of documents deleted.</returns>
|
||||||
long DeleteMany<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
long DeleteMany<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes the documents matching the condition of the LINQ expression filter.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
||||||
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
|
/// <returns>The number of documents deleted.</returns>
|
||||||
|
long DeleteMany<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Project
|
#region Project
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously returns a projected document matching the filter condition.
|
/// Asynchronously returns a projected document matching the filter condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <typeparam name="TProjection"></typeparam>
|
/// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam>
|
||||||
/// <param name="filter"></param>
|
/// <param name="filter"></param>
|
||||||
/// <param name="projection">The projection expression.</param>
|
/// <param name="projection">The projection expression.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
@@ -253,11 +265,25 @@ namespace MongoDbGenericRepository
|
|||||||
where TDocument : IDocument
|
where TDocument : IDocument
|
||||||
where TProjection : class;
|
where TProjection : class;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously returns a projected document matching the filter condition.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
||||||
|
/// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam>
|
||||||
|
/// <param name="filter"></param>
|
||||||
|
/// <param name="projection">The projection expression.</param>
|
||||||
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
|
Task<TProjection> ProjectOneAsync<TDocument, TProjection, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TProjection>> projection, string partitionKey = null)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
where TProjection : class;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a projected document matching the filter condition.
|
/// Returns a projected document matching the filter condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <typeparam name="TProjection"></typeparam>
|
/// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam>
|
||||||
/// <param name="filter"></param>
|
/// <param name="filter"></param>
|
||||||
/// <param name="projection">The projection expression.</param>
|
/// <param name="projection">The projection expression.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
@@ -265,11 +291,25 @@ namespace MongoDbGenericRepository
|
|||||||
where TDocument : IDocument
|
where TDocument : IDocument
|
||||||
where TProjection : class;
|
where TProjection : class;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a projected document matching the filter condition.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
||||||
|
/// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam>
|
||||||
|
/// <param name="filter"></param>
|
||||||
|
/// <param name="projection">The projection expression.</param>
|
||||||
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
|
TProjection ProjectOne<TDocument, TProjection, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TProjection>> projection, string partitionKey = null)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
where TProjection : class;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously returns a list of projected documents matching the filter condition.
|
/// Asynchronously returns a list of projected documents matching the filter condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <typeparam name="TProjection"></typeparam>
|
/// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam>
|
||||||
/// <param name="filter"></param>
|
/// <param name="filter"></param>
|
||||||
/// <param name="projection">The projection expression.</param>
|
/// <param name="projection">The projection expression.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
@@ -280,8 +320,22 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously returns a list of projected documents matching the filter condition.
|
/// Asynchronously returns a list of projected documents matching the filter condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <typeparam name="TProjection"></typeparam>
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
||||||
|
/// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam>
|
||||||
|
/// <param name="filter"></param>
|
||||||
|
/// <param name="projection">The projection expression.</param>
|
||||||
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
|
Task<List<TProjection>> ProjectManyAsync<TDocument, TProjection, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TProjection>> projection, string partitionKey = null)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
where TProjection : class;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously returns a list of projected documents matching the filter condition.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam>
|
||||||
/// <param name="filter"></param>
|
/// <param name="filter"></param>
|
||||||
/// <param name="projection">The projection expression.</param>
|
/// <param name="projection">The projection expression.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
@@ -289,8 +343,70 @@ namespace MongoDbGenericRepository
|
|||||||
where TDocument : IDocument
|
where TDocument : IDocument
|
||||||
where TProjection : class;
|
where TProjection : class;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously returns a list of projected documents matching the filter condition.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
||||||
|
/// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam>
|
||||||
|
/// <param name="filter"></param>
|
||||||
|
/// <param name="projection">The projection expression.</param>
|
||||||
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
|
List<TProjection> ProjectMany<TDocument, TProjection, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TProjection>> projection, string partitionKey = null)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
where TProjection : class;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously returns a paginated list of the documents matching the filter condition.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <param name="filter"></param>
|
||||||
|
/// <param name="skipNumber">The number of documents you want to skip. Default value is 0.</param>
|
||||||
|
/// <param name="takeNumber">The number of documents you want to take. Default value is 50.</param>
|
||||||
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
|
Task<List<TDocument>> GetPaginatedAsync<TDocument>(Expression<Func<TDocument, bool>> filter, int skipNumber = 0, int takeNumber = 50, string partitionKey = null)
|
||||||
|
where TDocument : IDocument;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously returns a paginated list of the documents matching the filter condition.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
||||||
|
/// <param name="filter"></param>
|
||||||
|
/// <param name="skipNumber">The number of documents you want to skip. Default value is 0.</param>
|
||||||
|
/// <param name="takeNumber">The number of documents you want to take. Default value is 50.</param>
|
||||||
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
|
Task<List<TDocument>> GetPaginatedAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, int skipNumber = 0, int takeNumber = 50, string partitionKey = null)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// GetAndUpdateOne with filter
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <param name="filter"></param>
|
||||||
|
/// <param name="update"></param>
|
||||||
|
/// <param name="options"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<TDocument> GetAndUpdateOne<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> update, FindOneAndUpdateOptions<TDocument, TDocument> options)
|
||||||
|
where TDocument : IDocument;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// GetAndUpdateOne with filter
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
||||||
|
/// <param name="filter"></param>
|
||||||
|
/// <param name="update"></param>
|
||||||
|
/// <param name="options"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<TDocument> GetAndUpdateOne<TDocument, TKey>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> update, FindOneAndUpdateOptions<TDocument, TDocument> options)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -338,7 +454,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// Asynchronously adds a document to the collection.
|
/// Asynchronously adds a document to the collection.
|
||||||
/// Populates the Id and AddedAtUtc fields if necessary.
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="document">The document you want to add.</param>
|
/// <param name="document">The document you want to add.</param>
|
||||||
public async Task AddOneAsync<TDocument>(TDocument document) where TDocument : IDocument
|
public async Task AddOneAsync<TDocument>(TDocument document) where TDocument : IDocument
|
||||||
{
|
{
|
||||||
@@ -350,7 +466,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// Adds a document to the collection.
|
/// Adds a document to the collection.
|
||||||
/// Populates the Id and AddedAtUtc fields if necessary.
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="document">The document you want to add.</param>
|
/// <param name="document">The document you want to add.</param>
|
||||||
public void AddOne<TDocument>(TDocument document) where TDocument : IDocument
|
public void AddOne<TDocument>(TDocument document) where TDocument : IDocument
|
||||||
{
|
{
|
||||||
@@ -362,7 +478,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// Asynchronously adds a list of documents to the collection.
|
/// Asynchronously adds a list of documents to the collection.
|
||||||
/// Populates the Id and AddedAtUtc fields if necessary.
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="documents">The documents you want to add.</param>
|
/// <param name="documents">The documents you want to add.</param>
|
||||||
public async Task AddManyAsync<TDocument>(IEnumerable<TDocument> documents) where TDocument : IDocument
|
public async Task AddManyAsync<TDocument>(IEnumerable<TDocument> documents) where TDocument : IDocument
|
||||||
{
|
{
|
||||||
@@ -381,7 +497,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// Adds a list of documents to the collection.
|
/// Adds a list of documents to the collection.
|
||||||
/// Populates the Id and AddedAtUtc fields if necessary.
|
/// Populates the Id and AddedAtUtc fields if necessary.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="documents">The documents you want to add.</param>
|
/// <param name="documents">The documents you want to add.</param>
|
||||||
public void AddMany<TDocument>(IEnumerable<TDocument> documents) where TDocument : IDocument
|
public void AddMany<TDocument>(IEnumerable<TDocument> documents) where TDocument : IDocument
|
||||||
{
|
{
|
||||||
@@ -403,7 +519,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously returns one document given its id.
|
/// Asynchronously returns one document given its id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="id">The Id of the document you want to get.</param>
|
/// <param name="id">The Id of the document you want to get.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
public async Task<TDocument> GetByIdAsync<TDocument>(Guid id, string partitionKey = null) where TDocument : IDocument
|
public async Task<TDocument> GetByIdAsync<TDocument>(Guid id, string partitionKey = null) where TDocument : IDocument
|
||||||
@@ -415,7 +531,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns one document given its id.
|
/// Returns one document given its id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="id">The Id of the document you want to get.</param>
|
/// <param name="id">The Id of the document you want to get.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
public TDocument GetById<TDocument>(Guid id, string partitionKey = null) where TDocument : IDocument
|
public TDocument GetById<TDocument>(Guid id, string partitionKey = null) where TDocument : IDocument
|
||||||
@@ -427,7 +543,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously returns one document given an expression filter.
|
/// Asynchronously returns one document given an expression filter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
public async Task<TDocument> GetOneAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
|
public async Task<TDocument> GetOneAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
|
||||||
@@ -438,7 +554,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns one document given an expression filter.
|
/// Returns one document given an expression filter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
public TDocument GetOne<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
|
public TDocument GetOne<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
|
||||||
@@ -449,7 +565,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a collection cursor.
|
/// Returns a collection cursor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
public IFindFluent<TDocument, TDocument> GetCursor<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
|
public IFindFluent<TDocument, TDocument> GetCursor<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
|
||||||
@@ -460,7 +576,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
public async Task<bool> AnyAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
|
public async Task<bool> AnyAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
|
||||||
@@ -472,7 +588,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
public bool Any<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
|
public bool Any<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
|
||||||
@@ -484,7 +600,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously returns a list of the documents matching the filter condition.
|
/// Asynchronously returns a list of the documents matching the filter condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
public async Task<List<TDocument>> GetAllAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
|
public async Task<List<TDocument>> GetAllAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
|
||||||
@@ -495,7 +611,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a list of the documents matching the filter condition.
|
/// Returns a list of the documents matching the filter condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
public List<TDocument> GetAll<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
|
public List<TDocument> GetAll<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
|
||||||
@@ -506,7 +622,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously counts how many documents match the filter condition.
|
/// Asynchronously counts how many documents match the filter condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partitionKey</param>
|
/// <param name="partitionKey">An optional partitionKey</param>
|
||||||
public async Task<long> CountAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
|
public async Task<long> CountAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
|
||||||
@@ -517,7 +633,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Counts how many documents match the filter condition.
|
/// Counts how many documents match the filter condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partitionKey</param>
|
/// <param name="partitionKey">An optional partitionKey</param>
|
||||||
public long Count<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
|
public long Count<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
|
||||||
@@ -532,7 +648,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously Updates a document.
|
/// Asynchronously Updates a document.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
|
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
|
||||||
public async Task<bool> UpdateOneAsync<TDocument>(TDocument modifiedDocument) where TDocument : IDocument
|
public async Task<bool> UpdateOneAsync<TDocument>(TDocument modifiedDocument) where TDocument : IDocument
|
||||||
{
|
{
|
||||||
@@ -543,7 +659,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates a document.
|
/// Updates a document.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
|
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
|
||||||
public bool UpdateOne<TDocument>(TDocument modifiedDocument) where TDocument : IDocument
|
public bool UpdateOne<TDocument>(TDocument modifiedDocument) where TDocument : IDocument
|
||||||
{
|
{
|
||||||
@@ -558,7 +674,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously deletes a document.
|
/// Asynchronously deletes a document.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="document">The document you want to delete.</param>
|
/// <param name="document">The document you want to delete.</param>
|
||||||
/// <returns>The number of documents deleted.</returns>
|
/// <returns>The number of documents deleted.</returns>
|
||||||
public async Task<long> DeleteOneAsync<TDocument>(TDocument document) where TDocument : IDocument
|
public async Task<long> DeleteOneAsync<TDocument>(TDocument document) where TDocument : IDocument
|
||||||
@@ -569,7 +685,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes a document.
|
/// Deletes a document.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="document">The document you want to delete.</param>
|
/// <param name="document">The document you want to delete.</param>
|
||||||
/// <returns>The number of documents deleted.</returns>
|
/// <returns>The number of documents deleted.</returns>
|
||||||
public long DeleteOne<TDocument>(TDocument document) where TDocument : IDocument
|
public long DeleteOne<TDocument>(TDocument document) where TDocument : IDocument
|
||||||
@@ -580,7 +696,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes a document matching the condition of the LINQ expression filter.
|
/// Deletes a document matching the condition of the LINQ expression filter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
/// <returns>The number of documents deleted.</returns>
|
/// <returns>The number of documents deleted.</returns>
|
||||||
@@ -592,7 +708,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously deletes a document matching the condition of the LINQ expression filter.
|
/// Asynchronously deletes a document matching the condition of the LINQ expression filter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
/// <returns>The number of documents deleted.</returns>
|
/// <returns>The number of documents deleted.</returns>
|
||||||
@@ -604,7 +720,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously deletes the documents matching the condition of the LINQ expression filter.
|
/// Asynchronously deletes the documents matching the condition of the LINQ expression filter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
/// <returns>The number of documents deleted.</returns>
|
/// <returns>The number of documents deleted.</returns>
|
||||||
@@ -616,7 +732,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously deletes a list of documents.
|
/// Asynchronously deletes a list of documents.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="documents">The list of documents to delete.</param>
|
/// <param name="documents">The list of documents to delete.</param>
|
||||||
/// <returns>The number of documents deleted.</returns>
|
/// <returns>The number of documents deleted.</returns>
|
||||||
public async Task<long> DeleteManyAsync<TDocument>(IEnumerable<TDocument> documents) where TDocument : IDocument
|
public async Task<long> DeleteManyAsync<TDocument>(IEnumerable<TDocument> documents) where TDocument : IDocument
|
||||||
@@ -632,7 +748,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes a list of documents.
|
/// Deletes a list of documents.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="documents">The list of documents to delete.</param>
|
/// <param name="documents">The list of documents to delete.</param>
|
||||||
/// <returns>The number of documents deleted.</returns>
|
/// <returns>The number of documents deleted.</returns>
|
||||||
public long DeleteMany<TDocument>(IEnumerable<TDocument> documents) where TDocument : IDocument
|
public long DeleteMany<TDocument>(IEnumerable<TDocument> documents) where TDocument : IDocument
|
||||||
@@ -645,10 +761,29 @@ namespace MongoDbGenericRepository
|
|||||||
return HandlePartitioned(documents.FirstOrDefault()).DeleteMany(x => idsTodelete.Contains(x.Id)).DeletedCount;
|
return HandlePartitioned(documents.FirstOrDefault()).DeleteMany(x => idsTodelete.Contains(x.Id)).DeletedCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes a list of documents.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
||||||
|
/// <param name="documents">The list of documents to delete.</param>
|
||||||
|
/// <returns>The number of documents deleted.</returns>
|
||||||
|
public long DeleteMany<TDocument, TKey>(IEnumerable<TDocument> documents)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
if (!documents.Any())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
var idsTodelete = documents.Select(e => e.Id).ToArray();
|
||||||
|
return HandlePartitioned<TDocument, TKey>(documents.FirstOrDefault()).DeleteMany(x => idsTodelete.Contains(x.Id)).DeletedCount;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes the documents matching the condition of the LINQ expression filter.
|
/// Deletes the documents matching the condition of the LINQ expression filter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter">A LINQ expression filter.</param>
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
/// <returns>The number of documents deleted.</returns>
|
/// <returns>The number of documents deleted.</returns>
|
||||||
@@ -657,6 +792,21 @@ namespace MongoDbGenericRepository
|
|||||||
return HandlePartitioned<TDocument>(partitionKey).DeleteMany(filter).DeletedCount;
|
return HandlePartitioned<TDocument>(partitionKey).DeleteMany(filter).DeletedCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes the documents matching the condition of the LINQ expression filter.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
||||||
|
/// <param name="filter">A LINQ expression filter.</param>
|
||||||
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
|
/// <returns>The number of documents deleted.</returns>
|
||||||
|
public long DeleteMany<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
return HandlePartitioned<TDocument, TKey>(partitionKey).DeleteMany(filter).DeletedCount;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion Delete
|
#endregion Delete
|
||||||
|
|
||||||
#region Project
|
#region Project
|
||||||
@@ -664,8 +814,8 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously returns a projected document matching the filter condition.
|
/// Asynchronously returns a projected document matching the filter condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <typeparam name="TProjection"></typeparam>
|
/// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam>
|
||||||
/// <param name="filter"></param>
|
/// <param name="filter"></param>
|
||||||
/// <param name="projection">The projection expression.</param>
|
/// <param name="projection">The projection expression.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
@@ -678,11 +828,30 @@ namespace MongoDbGenericRepository
|
|||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously returns a projected document matching the filter condition.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
||||||
|
/// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam>
|
||||||
|
/// <param name="filter"></param>
|
||||||
|
/// <param name="projection">The projection expression.</param>
|
||||||
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
|
public async Task<TProjection> ProjectOneAsync<TDocument, TProjection, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TProjection>> projection, string partitionKey = null)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
where TProjection : class
|
||||||
|
{
|
||||||
|
return await HandlePartitioned<TDocument, TKey>(partitionKey).Find(filter)
|
||||||
|
.Project(projection)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a projected document matching the filter condition.
|
/// Returns a projected document matching the filter condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <typeparam name="TProjection"></typeparam>
|
/// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam>
|
||||||
/// <param name="filter"></param>
|
/// <param name="filter"></param>
|
||||||
/// <param name="projection">The projection expression.</param>
|
/// <param name="projection">The projection expression.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
@@ -695,11 +864,30 @@ namespace MongoDbGenericRepository
|
|||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a projected document matching the filter condition.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
||||||
|
/// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam>
|
||||||
|
/// <param name="filter"></param>
|
||||||
|
/// <param name="projection">The projection expression.</param>
|
||||||
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
|
public TProjection ProjectOne<TDocument, TProjection, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TProjection>> projection, string partitionKey = null)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
where TProjection : class
|
||||||
|
{
|
||||||
|
return HandlePartitioned<TDocument, TKey>(partitionKey).Find(filter)
|
||||||
|
.Project(projection)
|
||||||
|
.FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously returns a list of projected documents matching the filter condition.
|
/// Asynchronously returns a list of projected documents matching the filter condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <typeparam name="TProjection"></typeparam>
|
/// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam>
|
||||||
/// <param name="filter"></param>
|
/// <param name="filter"></param>
|
||||||
/// <param name="projection">The projection expression.</param>
|
/// <param name="projection">The projection expression.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
@@ -715,8 +903,27 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously returns a list of projected documents matching the filter condition.
|
/// Asynchronously returns a list of projected documents matching the filter condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <typeparam name="TProjection"></typeparam>
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
||||||
|
/// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam>
|
||||||
|
/// <param name="filter"></param>
|
||||||
|
/// <param name="projection">The projection expression.</param>
|
||||||
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
|
public async Task<List<TProjection>> ProjectManyAsync<TDocument, TProjection, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TProjection>> projection, string partitionKey = null)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
where TProjection : class
|
||||||
|
{
|
||||||
|
return await HandlePartitioned<TDocument, TKey>(partitionKey).Find(filter)
|
||||||
|
.Project(projection)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously returns a list of projected documents matching the filter condition.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam>
|
||||||
/// <param name="filter"></param>
|
/// <param name="filter"></param>
|
||||||
/// <param name="projection">The projection expression.</param>
|
/// <param name="projection">The projection expression.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
@@ -729,27 +936,63 @@ namespace MongoDbGenericRepository
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously returns a list of projected documents matching the filter condition.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
||||||
|
/// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam>
|
||||||
|
/// <param name="filter"></param>
|
||||||
|
/// <param name="projection">The projection expression.</param>
|
||||||
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
|
public List<TProjection> ProjectMany<TDocument, TProjection, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TProjection>> projection, string partitionKey = null)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
where TProjection : class
|
||||||
|
{
|
||||||
|
return HandlePartitioned<TDocument, TKey>(partitionKey).Find(filter)
|
||||||
|
.Project(projection)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronously returns a paginated list of the documents matching the filter condition.
|
/// Asynchronously returns a paginated list of the documents matching the filter condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter"></param>
|
/// <param name="filter"></param>
|
||||||
/// <param name="skipNumber">The number of documents you want to skip. Default value is 0.</param>
|
/// <param name="skipNumber">The number of documents you want to skip. Default value is 0.</param>
|
||||||
/// <param name="takeNumber">The number of documents you want to take. Default value is 50.</param>
|
/// <param name="takeNumber">The number of documents you want to take. Default value is 50.</param>
|
||||||
/// <param name="partitionKey">An optional partition key.</param>
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
public async Task<List<TDocument>> GetPaginatedAsync<TDocument>(Expression<Func<TDocument, bool>> filter, int skipNumber = 0, int takeNumber = 50, string partitionKey = null) where TDocument : IDocument
|
public async Task<List<TDocument>> GetPaginatedAsync<TDocument>(Expression<Func<TDocument, bool>> filter, int skipNumber = 0, int takeNumber = 50, string partitionKey = null)
|
||||||
|
where TDocument : IDocument
|
||||||
{
|
{
|
||||||
return await HandlePartitioned<TDocument>(partitionKey).Find(filter).Skip(skipNumber).Limit(takeNumber).ToListAsync();
|
return await HandlePartitioned<TDocument>(partitionKey).Find(filter).Skip(skipNumber).Limit(takeNumber).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asynchronously returns a paginated list of the documents matching the filter condition.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
||||||
|
/// <param name="filter"></param>
|
||||||
|
/// <param name="skipNumber">The number of documents you want to skip. Default value is 0.</param>
|
||||||
|
/// <param name="takeNumber">The number of documents you want to take. Default value is 50.</param>
|
||||||
|
/// <param name="partitionKey">An optional partition key.</param>
|
||||||
|
public async Task<List<TDocument>> GetPaginatedAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, int skipNumber = 0, int takeNumber = 50, string partitionKey = null)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
return await HandlePartitioned<TDocument, TKey>(partitionKey).Find(filter).Skip(skipNumber).Limit(takeNumber).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
#region Find And Update
|
#region Find And Update
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// GetAndUpdateOne with filter
|
/// GetAndUpdateOne with filter
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="filter"></param>
|
/// <param name="filter"></param>
|
||||||
/// <param name="update"></param>
|
/// <param name="update"></param>
|
||||||
/// <param name="options"></param>
|
/// <param name="options"></param>
|
||||||
@@ -759,6 +1002,22 @@ namespace MongoDbGenericRepository
|
|||||||
return await GetCollection<TDocument>().FindOneAndUpdateAsync(filter, update, options);
|
return await GetCollection<TDocument>().FindOneAndUpdateAsync(filter, update, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// GetAndUpdateOne with filter
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
||||||
|
/// <param name="filter"></param>
|
||||||
|
/// <param name="update"></param>
|
||||||
|
/// <param name="options"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<TDocument> GetAndUpdateOne<TDocument, TKey>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> update, FindOneAndUpdateOptions<TDocument, TDocument> options)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
return await GetCollection<TDocument, TKey>().FindOneAndUpdateAsync(filter, update, options);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion Find And Update
|
#endregion Find And Update
|
||||||
|
|
||||||
#region Private Methods
|
#region Private Methods
|
||||||
@@ -782,6 +1041,17 @@ namespace MongoDbGenericRepository
|
|||||||
return GetCollection<TDocument>();
|
return GetCollection<TDocument>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IMongoCollection<TDocument> HandlePartitioned<TDocument, TKey>(TDocument document)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
if (document is IPartitionedDocument)
|
||||||
|
{
|
||||||
|
return GetCollection<TDocument, TKey>(((IPartitionedDocument)document).PartitionKey);
|
||||||
|
}
|
||||||
|
return GetCollection<TDocument, TKey>();
|
||||||
|
}
|
||||||
|
|
||||||
private IMongoCollection<TDocument> HandlePartitioned<TDocument>(string partitionKey) where TDocument : IDocument
|
private IMongoCollection<TDocument> HandlePartitioned<TDocument>(string partitionKey) where TDocument : IDocument
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(partitionKey))
|
if (!string.IsNullOrEmpty(partitionKey))
|
||||||
@@ -803,6 +1073,42 @@ namespace MongoDbGenericRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private IMongoCollection<TDocument> GetCollection<TDocument, TKey>(string partitionKey)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
return MongoDbContext.GetCollection<TDocument, TKey>(partitionKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IMongoCollection<TDocument> GetCollection<TDocument, TKey>()
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
return MongoDbContext.GetCollection<TDocument>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private IMongoCollection<TDocument> HandlePartitioned<TDocument, TKey>(string partitionKey)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(partitionKey))
|
||||||
|
{
|
||||||
|
return GetCollection<TDocument, TKey>(partitionKey);
|
||||||
|
}
|
||||||
|
return GetCollection<TDocument, TKey>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormatDocument<TDocument, TKey>(TDocument document)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
if (document == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(document));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using MongoDB.Driver;
|
using MongoDB.Driver;
|
||||||
using MongoDbGenericRepository.Models;
|
using MongoDbGenericRepository.Models;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace MongoDbGenericRepository
|
namespace MongoDbGenericRepository
|
||||||
{
|
{
|
||||||
@@ -31,6 +32,16 @@ namespace MongoDbGenericRepository
|
|||||||
/// <param name="partitionKey">The value of the partition key.</param>
|
/// <param name="partitionKey">The value of the partition key.</param>
|
||||||
IMongoCollection<TDocument> GetCollection<TDocument>(string partitionKey) where TDocument : IDocument;
|
IMongoCollection<TDocument> GetCollection<TDocument>(string partitionKey) where TDocument : IDocument;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a collection for a document type that has a partition key.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
||||||
|
/// <param name="partitionKey">The value of the partition key.</param>
|
||||||
|
IMongoCollection<TDocument> GetCollection<TDocument, TKey>(string partitionKey)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Drops a collection, use very carefully.
|
/// Drops a collection, use very carefully.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -6,16 +6,24 @@ namespace MongoDbGenericRepository.Models
|
|||||||
/// This class represents a basic document that can be stored in MongoDb.
|
/// This class represents a basic document that can be stored in MongoDb.
|
||||||
/// Your document must implement this class in order for the MongoDbRepository to handle them.
|
/// Your document must implement this class in order for the MongoDbRepository to handle them.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IDocument
|
public interface IDocument<TKey> where TKey : IEquatable<TKey>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Guid, which must be decorated with the [BsonId] attribute
|
/// The Guid, which must be decorated with the [BsonId] attribute
|
||||||
/// if you want the MongoDb C# driver to consider it to be the document ID.
|
/// if you want the MongoDb C# driver to consider it to be the document ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Guid Id { get; set; }
|
TKey Id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A version number, to indicate the version of the schema.
|
/// A version number, to indicate the version of the schema.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int Version { get; set; }
|
int Version { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class represents a basic document that can be stored in MongoDb.
|
||||||
|
/// Your document must implement this class in order for the MongoDbRepository to handle them.
|
||||||
|
/// </summary>
|
||||||
|
public interface IDocument: IDocument<Guid>
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
/// This can be useful if you are planning to build a Software as a Service (SaaS) Platform, or if you want to reduce indexing.
|
/// This can be useful if you are planning to build a Software as a Service (SaaS) Platform, or if you want to reduce indexing.
|
||||||
/// You could for example insert Logs in different collections based on the week and year they where created, or their Log category/source.
|
/// You could for example insert Logs in different collections based on the week and year they where created, or their Log category/source.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IPartitionedDocument : IDocument
|
public interface IPartitionedDocument
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The partition key used to partition your collection.
|
/// The partition key used to partition your collection.
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using MongoDB.Driver;
|
using MongoDB.Driver;
|
||||||
using MongoDbGenericRepository.Models;
|
using MongoDbGenericRepository.Models;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace MongoDbGenericRepository
|
namespace MongoDbGenericRepository
|
||||||
{
|
{
|
||||||
@@ -48,7 +49,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The private GetCollection method
|
/// The private GetCollection method
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public IMongoCollection<TDocument> GetCollection<TDocument>()
|
public IMongoCollection<TDocument> GetCollection<TDocument>()
|
||||||
{
|
{
|
||||||
@@ -58,17 +59,30 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a collection for a document type that has a partition key.
|
/// Returns a collection for a document type that has a partition key.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <param name="partitionKey">The value of the partition key.</param>
|
/// <param name="partitionKey">The value of the partition key.</param>
|
||||||
public IMongoCollection<TDocument> GetCollection<TDocument>(string partitionKey) where TDocument : IDocument
|
public IMongoCollection<TDocument> GetCollection<TDocument>(string partitionKey) where TDocument : IDocument
|
||||||
{
|
{
|
||||||
return Database.GetCollection<TDocument>(partitionKey +"-"+ Pluralize<TDocument>());
|
return Database.GetCollection<TDocument>(partitionKey +"-"+ Pluralize<TDocument>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a collection for a document type that has a partition key.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
|
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
|
||||||
|
/// <param name="partitionKey">The value of the partition key.</param>
|
||||||
|
public IMongoCollection<TDocument> GetCollection<TDocument, TKey>(string partitionKey)
|
||||||
|
where TDocument : IDocument<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
return Database.GetCollection<TDocument>(partitionKey + "-" + Pluralize<TDocument>());
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Drops a collection, use very carefully.
|
/// Drops a collection, use very carefully.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
public void DropCollection<TDocument>()
|
public void DropCollection<TDocument>()
|
||||||
{
|
{
|
||||||
Database.DropCollection(Pluralize<TDocument>());
|
Database.DropCollection(Pluralize<TDocument>());
|
||||||
@@ -77,7 +91,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Drops a collection having a partitionkey, use very carefully.
|
/// Drops a collection having a partitionkey, use very carefully.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
public void DropCollection<TDocument>(string partitionKey)
|
public void DropCollection<TDocument>(string partitionKey)
|
||||||
{
|
{
|
||||||
Database.DropCollection(partitionKey + "-" + Pluralize<TDocument>());
|
Database.DropCollection(partitionKey + "-" + Pluralize<TDocument>());
|
||||||
@@ -86,7 +100,7 @@ namespace MongoDbGenericRepository
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Very naively pluralizes a TDocument type name.
|
/// Very naively pluralizes a TDocument type name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDocument"></typeparam>
|
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private string Pluralize<TDocument>()
|
private string Pluralize<TDocument>()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user