Ascending index tests and Descending Index and tests

This commit is contained in:
Sean Garrett
2023-06-24 17:08:26 +01:00
parent 251ffdacfa
commit 807a4b17ce
12 changed files with 1768 additions and 98 deletions
@@ -1,29 +1,32 @@
using MongoDbGenericRepository.DataAccess.Index;
using System;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using MongoDbGenericRepository.DataAccess.Index;
using MongoDbGenericRepository.Models;
namespace MongoDbGenericRepository
{
/// <summary>
/// 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.
/// </summary>
public abstract partial class BaseMongoRepository : IBaseMongoRepository_Index
{
private IMongoDbIndexHandler _mongoDbIndexHandler;
/// <summary>
/// The MongoDb accessor to manage indexes.
/// The MongoDb accessor to manage indexes.
/// </summary>
protected virtual IMongoDbIndexHandler MongoDbIndexHandler
{
get
{
if (_mongoDbIndexHandler != null) { return _mongoDbIndexHandler; }
if (_mongoDbIndexHandler != null)
{
return _mongoDbIndexHandler;
}
lock (_initLock)
{
@@ -32,9 +35,10 @@ namespace MongoDbGenericRepository
_mongoDbIndexHandler = new MongoDbIndexHandler(MongoDbContext);
}
}
return _mongoDbIndexHandler;
}
set { _mongoDbIndexHandler = value; }
set => _mongoDbIndexHandler = value;
}
/// <inheritdoc />
@@ -120,7 +124,10 @@ namespace MongoDbGenericRepository
}
/// <inheritdoc />
public async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
public async Task<string> CreateTextIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<Guid>
{
return await CreateTextIndexAsync<TDocument, Guid>(field, null, partitionKey, cancellationToken);
@@ -134,21 +141,31 @@ namespace MongoDbGenericRepository
}
/// <inheritdoc />
public async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
public async Task<string> CreateTextIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
CancellationToken cancellationToken)
where TDocument : IDocument<Guid>
{
return await CreateTextIndexAsync<TDocument, Guid>(field, indexCreationOptions, null, cancellationToken);
}
/// <inheritdoc />
public async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
public async Task<string> CreateTextIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
string partitionKey)
where TDocument : IDocument<Guid>
{
return await CreateTextIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
public async Task<string> CreateTextIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<Guid>
{
return await CreateTextIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey, cancellationToken);
@@ -179,7 +196,10 @@ namespace MongoDbGenericRepository
}
/// <inheritdoc />
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(
Expression<Func<TDocument, object>> field,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
@@ -187,7 +207,9 @@ namespace MongoDbGenericRepository
}
/// <inheritdoc />
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
@@ -195,7 +217,10 @@ namespace MongoDbGenericRepository
}
/// <inheritdoc />
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
@@ -203,7 +228,10 @@ namespace MongoDbGenericRepository
}
/// <inheritdoc />
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
@@ -211,7 +239,11 @@ namespace MongoDbGenericRepository
}
/// <inheritdoc />
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
public virtual async Task<string> CreateTextIndexAsync<TDocument, TKey>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
@@ -219,44 +251,291 @@ namespace MongoDbGenericRepository
}
/// <inheritdoc />
public async Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
public async Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field)
where TDocument : IDocument<Guid>
{
return await CreateAscendingIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey);
return await CreateAscendingIndexAsync<TDocument, Guid>(field, null, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateAscendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
public async Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
where TDocument : IDocument<Guid>
{
return await CreateAscendingIndexAsync<TDocument, Guid>(field, null, null, cancellationToken);
}
/// <inheritdoc />
public async Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
where TDocument : IDocument<Guid>
{
return await CreateAscendingIndexAsync<TDocument, Guid>(field, indexCreationOptions, null, CancellationToken.None);
}
/// <inheritdoc />
public async Task<string> CreateAscendingIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
CancellationToken cancellationToken)
where TDocument : IDocument<Guid>
{
return await CreateAscendingIndexAsync<TDocument, Guid>(field, indexCreationOptions, null, cancellationToken);
}
/// <inheritdoc />
public async Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey)
where TDocument : IDocument<Guid>
{
return await CreateAscendingIndexAsync<TDocument, Guid>(field, null, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public async Task<string> CreateAscendingIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<Guid>
{
return await CreateAscendingIndexAsync<TDocument, Guid>(field, null, partitionKey, cancellationToken);
}
/// <inheritdoc />
public async Task<string> CreateAscendingIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
string partitionKey)
where TDocument : IDocument<Guid>
{
return await CreateAscendingIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public async Task<string> CreateAscendingIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<Guid>
{
return await CreateAscendingIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateAscendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await MongoDbIndexHandler.CreateAscendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
return await CreateAscendingIndexAsync<TDocument, TKey>(field, null, null, CancellationToken.None);
}
/// <inheritdoc />
public async Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
where TDocument : IDocument<Guid>
{
return await CreateDescendingIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey);
}
/// <inheritdoc />
public virtual async Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
public virtual async Task<string> CreateAscendingIndexAsync<TDocument, TKey>(
Expression<Func<TDocument, object>> field,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await MongoDbIndexHandler.CreateDescendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
return await CreateAscendingIndexAsync<TDocument, TKey>(field, null, null, cancellationToken);
}
/// <inheritdoc />
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
public virtual async Task<string> CreateAscendingIndexAsync<TDocument, TKey>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await CreateAscendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateAscendingIndexAsync<TDocument, TKey>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await CreateAscendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateAscendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await CreateAscendingIndexAsync<TDocument, TKey>(field, null, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateAscendingIndexAsync<TDocument, TKey>(
Expression<Func<TDocument, object>> field,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await CreateAscendingIndexAsync<TDocument, TKey>(field, null, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateAscendingIndexAsync<TDocument, TKey>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await CreateAscendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateAscendingIndexAsync<TDocument, TKey>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await MongoDbIndexHandler.CreateAscendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey, cancellationToken);
}
/// <inheritdoc />
public async Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field)
where TDocument : IDocument<Guid>
{
return await CreateDescendingIndexAsync<TDocument, Guid>(field, null, null, CancellationToken.None);
}
/// <inheritdoc />
public async Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
where TDocument : IDocument<Guid>
{
return await CreateDescendingIndexAsync<TDocument, Guid>(field, null, null, cancellationToken);
}
/// <inheritdoc />
public async Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
where TDocument : IDocument<Guid>
{
return await CreateDescendingIndexAsync<TDocument, Guid>(field, indexCreationOptions, null, CancellationToken.None);
}
/// <inheritdoc />
public async Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
where TDocument : IDocument<Guid>
{
return await CreateDescendingIndexAsync<TDocument, Guid>(field, indexCreationOptions, null, cancellationToken);
}
/// <inheritdoc />
public async Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey)
where TDocument : IDocument<Guid>
{
return await CreateDescendingIndexAsync<TDocument, Guid>(field, null, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public async Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<Guid>
{
return await CreateDescendingIndexAsync<TDocument, Guid>(field, null, partitionKey, cancellationToken);
}
/// <inheritdoc />
public async Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
where TDocument : IDocument<Guid>
{
return await CreateDescendingIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public async Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<Guid>
{
return await CreateDescendingIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await CreateDescendingIndexAsync<TDocument, TKey>(field, null, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await CreateDescendingIndexAsync<TDocument, TKey>(field, null, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await CreateDescendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await CreateDescendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await CreateDescendingIndexAsync<TDocument, TKey>(field, null, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await CreateDescendingIndexAsync<TDocument, TKey>(field, null, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await CreateDescendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await MongoDbIndexHandler.CreateDescendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey, cancellationToken);
}
/// <inheritdoc />
public async Task<string> CreateHashedIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions = null,
string partitionKey = null)
where TDocument : IDocument<Guid>
{
return await CreateHashedIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey);
}
/// <inheritdoc />
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions = null,
string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
@@ -264,14 +543,20 @@ namespace MongoDbGenericRepository
}
/// <inheritdoc />
public async Task<string> CreateCombinedTextIndexAsync<TDocument>(IEnumerable<Expression<Func<TDocument, object>>> fields, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
public async Task<string> CreateCombinedTextIndexAsync<TDocument>(
IEnumerable<Expression<Func<TDocument, object>>> fields,
IndexCreationOptions indexCreationOptions = null,
string partitionKey = null)
where TDocument : IDocument<Guid>
{
return await CreateCombinedTextIndexAsync<TDocument, Guid>(fields, indexCreationOptions, partitionKey);
}
/// <inheritdoc />
public virtual async Task<string> CreateCombinedTextIndexAsync<TDocument, TKey>(IEnumerable<Expression<Func<TDocument, object>>> fields, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
public virtual async Task<string> CreateCombinedTextIndexAsync<TDocument, TKey>(
IEnumerable<Expression<Func<TDocument, object>>> fields,
IndexCreationOptions indexCreationOptions = null,
string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
@@ -293,4 +578,4 @@ namespace MongoDbGenericRepository
await MongoDbIndexHandler.DropIndexAsync<TDocument, TKey>(indexName, partitionKey);
}
}
}
}
@@ -172,6 +172,91 @@ namespace MongoDbGenericRepository
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </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="field">The field we want to index.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateAscendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </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="field">The field we want to index.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateAscendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </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="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateAscendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </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="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateAscendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </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="field">The field we want to index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateAscendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </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="field">The field we want to index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateAscendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
@@ -183,7 +268,108 @@ namespace MongoDbGenericRepository
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateAscendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
Task<string> CreateAscendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </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="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateAscendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates an index on the given field in descending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </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="field">The field we want to index.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates an index on the given field in descending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </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="field">The field we want to index.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates an index on the given field in descending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </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="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates an index on the given field in descending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </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="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates an index on the given field in descending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </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="field">The field we want to index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates an index on the given field in descending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </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="field">The field we want to index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
@@ -198,7 +384,23 @@ namespace MongoDbGenericRepository
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates an index on the given field in descending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </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="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
@@ -1,16 +1,16 @@
using MongoDbGenericRepository.DataAccess.Index;
using MongoDbGenericRepository.Models;
using System;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using CancellationToken = System.Threading.CancellationToken;
using MongoDbGenericRepository.DataAccess.Index;
using MongoDbGenericRepository.Models;
namespace MongoDbGenericRepository
{
/// <summary>
/// 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.
/// </summary>
public abstract partial class BaseMongoRepository<TKey> : IBaseMongoRepository_Index<TKey>
where TKey : IEquatable<TKey>
@@ -18,13 +18,16 @@ namespace MongoDbGenericRepository
private IMongoDbIndexHandler _mongoDbIndexHandler;
/// <summary>
/// The MongoDb accessor to manage indexes.
/// The MongoDb accessor to manage indexes.
/// </summary>
protected virtual IMongoDbIndexHandler MongoDbIndexHandler
{
get
{
if (_mongoDbIndexHandler != null) { return _mongoDbIndexHandler; }
if (_mongoDbIndexHandler != null)
{
return _mongoDbIndexHandler;
}
lock (_initLock)
{
@@ -36,7 +39,7 @@ namespace MongoDbGenericRepository
return _mongoDbIndexHandler;
}
set { _mongoDbIndexHandler = value; }
set => _mongoDbIndexHandler = value;
}
/// <inheritdoc />
@@ -89,14 +92,20 @@ namespace MongoDbGenericRepository
}
/// <inheritdoc />
public virtual async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
public virtual async Task<string> CreateTextIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await CreateTextIndexAsync(field, indexCreationOptions, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
public virtual async Task<string> CreateTextIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
string partitionKey)
where TDocument : IDocument<TKey>
{
return await CreateTextIndexAsync(field, indexCreationOptions, partitionKey, CancellationToken.None);
@@ -110,31 +119,168 @@ namespace MongoDbGenericRepository
}
/// <inheritdoc />
public virtual async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
public virtual async Task<string> CreateTextIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await CreateTextIndexAsync(field, null, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
public virtual async Task<string> CreateTextIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await MongoDbIndexHandler.CreateTextIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
public virtual async Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field)
where TDocument : IDocument<TKey>
{
return await MongoDbIndexHandler.CreateAscendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
return await CreateAscendingIndexAsync(field, null, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
public virtual async Task<string> CreateAscendingIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await MongoDbIndexHandler.CreateDescendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
return await CreateAscendingIndexAsync(field, null, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateAscendingIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions)
where TDocument : IDocument<TKey>
{
return await CreateAscendingIndexAsync(field, indexCreationOptions, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateAscendingIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await CreateAscendingIndexAsync(field, indexCreationOptions, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey)
where TDocument : IDocument<TKey>
{
return await CreateAscendingIndexAsync(field, null, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateAscendingIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await CreateAscendingIndexAsync(field, null, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateAscendingIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
string partitionKey)
where TDocument : IDocument<TKey>
{
return await CreateAscendingIndexAsync(field, indexCreationOptions, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateAscendingIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await MongoDbIndexHandler.CreateAscendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field)
where TDocument : IDocument<TKey>
{
return await CreateDescendingIndexAsync(field, null, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await CreateDescendingIndexAsync(field, null, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateDescendingIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions)
where TDocument : IDocument<TKey>
{
return await CreateDescendingIndexAsync(field, indexCreationOptions, null, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateDescendingIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await CreateDescendingIndexAsync(field, indexCreationOptions, null, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey)
where TDocument : IDocument<TKey>
{
return await CreateDescendingIndexAsync(field, null, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateDescendingIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await CreateDescendingIndexAsync(field, null, partitionKey, cancellationToken);
}
/// <inheritdoc />
public virtual async Task<string> CreateDescendingIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
string partitionKey)
where TDocument : IDocument<TKey>
{
return await CreateDescendingIndexAsync(field, indexCreationOptions, partitionKey, CancellationToken.None);
}
/// <inheritdoc />
public virtual async Task<string> CreateDescendingIndexAsync<TDocument>(
Expression<Func<TDocument, object>> field,
IndexCreationOptions indexCreationOptions,
string partitionKey,
CancellationToken cancellationToken)
where TDocument : IDocument<TKey>
{
return await MongoDbIndexHandler.CreateDescendingIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey, cancellationToken);
}
/// <inheritdoc />
@@ -158,4 +304,4 @@ namespace MongoDbGenericRepository
await MongoDbIndexHandler.DropIndexAsync<TDocument, TKey>(indexName, partitionKey);
}
}
}
}
@@ -149,6 +149,80 @@ namespace MongoDbGenericRepository
Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
@@ -159,7 +233,94 @@ namespace MongoDbGenericRepository
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates an index on the given field in descending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates an index on the given field in descending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates an index on the given field in descending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates an index on the given field in descending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates an index on the given field in descending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates an index on the given field in descending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>
@@ -172,7 +333,21 @@ namespace MongoDbGenericRepository
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
where TDocument : IDocument<TKey>;
/// <summary>
/// Creates an index on the given field in descending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
where TDocument : IDocument<TKey>;
/// <summary>