Cancellation tokens on Create Hashed Index
This commit is contained in:
@@ -0,0 +1,294 @@
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using AutoFixture;
|
||||
using CoreUnitTests.Infrastructure.Model;
|
||||
using MongoDbGenericRepository.DataAccess.Index;
|
||||
using MongoDbGenericRepository.Models;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
using CancellationToken = System.Threading.CancellationToken;
|
||||
|
||||
namespace CoreUnitTests.BaseMongoRepositoryTests.IndexTests;
|
||||
|
||||
public class CreateHashedIndexAsyncTests : BaseIndexTests
|
||||
{
|
||||
private readonly Expression<Func<TestDocument, object>> fieldExpression = t => t.SomeContent2;
|
||||
private readonly Expression<Func<TestDocumentWithKey<int>, object>> keyedFieldExpression = t => t.SomeContent2;
|
||||
|
||||
[Fact]
|
||||
public async Task WithFieldExpression_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync(fieldExpression);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocument, Guid>(fieldExpression, null, null, CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WithFieldExpressionAndCancellationToken_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var token = new CancellationToken(true);
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync(fieldExpression, token);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocument, Guid>(fieldExpression, null, null, token));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WithFieldExpressionAndOptions_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var indexName = Fixture.Create<string>();
|
||||
var options = new IndexCreationOptions { Name = indexName };
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync(fieldExpression, options);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocument, Guid>(
|
||||
fieldExpression, options, null, CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WithFieldExpressionAndOptionsAndCancellationToken_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var indexName = Fixture.Create<string>();
|
||||
var options = new IndexCreationOptions { Name = indexName };
|
||||
var token = new CancellationToken(true);
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync(fieldExpression, options, token);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocument, Guid>(
|
||||
fieldExpression, options, null, token));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WithFieldExpressionAndPartitionKey_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var partitionKey = Fixture.Create<string>();
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync(fieldExpression, partitionKey);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocument, Guid>(
|
||||
fieldExpression, null, partitionKey, CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WithFieldExpressionAndPartitionKeyAndCancellationToken_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var partitionKey = Fixture.Create<string>();
|
||||
var token = new CancellationToken(true);
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync(fieldExpression, partitionKey, token);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocument, Guid>(
|
||||
fieldExpression, null, partitionKey, token));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WithFieldExpressionAndOptionsAndPartitionKey_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var partitionKey = Fixture.Create<string>();
|
||||
var indexName = Fixture.Create<string>();
|
||||
var options = new IndexCreationOptions { Name = indexName };
|
||||
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync(fieldExpression, options, partitionKey);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocument, Guid>(
|
||||
fieldExpression, options, partitionKey, CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WithFieldExpressionAndOptionsAndPartitionKeyAndCancellationToken_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var partitionKey = Fixture.Create<string>();
|
||||
var token = new CancellationToken(true);
|
||||
var indexName = Fixture.Create<string>();
|
||||
var options = new IndexCreationOptions { Name = indexName };
|
||||
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync(fieldExpression, options, partitionKey, token);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocument, Guid>(
|
||||
fieldExpression, options, partitionKey, token));
|
||||
}
|
||||
|
||||
#region Keyed
|
||||
|
||||
[Fact]
|
||||
public async Task Keyed_WithKeyedFieldExpression_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(keyedFieldExpression);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(keyedFieldExpression, null, null, CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Keyed_WithKeyedFieldExpressionAndCancellationToken_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var token = new CancellationToken(true);
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(keyedFieldExpression, token);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(keyedFieldExpression, null, null, token));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Keyed_WithKeyedFieldExpressionAndOptions_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var indexName = Fixture.Create<string>();
|
||||
var options = new IndexCreationOptions { Name = indexName };
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(keyedFieldExpression, options);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(
|
||||
keyedFieldExpression, options, null, CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Keyed_WithKeyedFieldExpressionAndOptionsAndCancellationToken_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var indexName = Fixture.Create<string>();
|
||||
var options = new IndexCreationOptions { Name = indexName };
|
||||
var token = new CancellationToken(true);
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(keyedFieldExpression, options, token);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(
|
||||
keyedFieldExpression, options, null, token));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Keyed_WithKeyedFieldExpressionAndPartitionKey_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var partitionKey = Fixture.Create<string>();
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(keyedFieldExpression, partitionKey);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(
|
||||
keyedFieldExpression, null, partitionKey, CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Keyed_WithKeyedFieldExpressionAndPartitionKeyAndCancellationToken_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var partitionKey = Fixture.Create<string>();
|
||||
var token = new CancellationToken(true);
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(keyedFieldExpression, partitionKey, token);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(
|
||||
keyedFieldExpression, null, partitionKey, token));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Keyed_WithKeyedFieldExpressionAndOptionsAndPartitionKey_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var partitionKey = Fixture.Create<string>();
|
||||
var indexName = Fixture.Create<string>();
|
||||
var options = new IndexCreationOptions { Name = indexName };
|
||||
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(keyedFieldExpression, options, partitionKey);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(
|
||||
keyedFieldExpression, options, partitionKey, CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Keyed_WithKeyedFieldExpressionAndOptionsAndPartitionKeyAndCancellationToken_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var partitionKey = Fixture.Create<string>();
|
||||
var token = new CancellationToken(true);
|
||||
var indexName = Fixture.Create<string>();
|
||||
var options = new IndexCreationOptions { Name = indexName };
|
||||
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(keyedFieldExpression, options, partitionKey, token);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(
|
||||
keyedFieldExpression, options, partitionKey, token));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AutoFixture;
|
||||
using CoreUnitTests.Infrastructure;
|
||||
using CoreUnitTests.Infrastructure.Model;
|
||||
using MongoDbGenericRepository.DataAccess.Index;
|
||||
using MongoDbGenericRepository.Models;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
namespace CoreUnitTests.KeyTypedRepositoryTests.IndexTests;
|
||||
|
||||
public class CreateHashedIndexAsyncTests : TestKeyedMongoRepositoryContext<int>
|
||||
{
|
||||
private readonly Expression<Func<TestDocumentWithKey<int>, object>> keyedFieldExpression = t => t.SomeContent2;
|
||||
|
||||
[Fact]
|
||||
public async Task WithFieldExpression_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync(keyedFieldExpression);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(keyedFieldExpression, null, null, CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WithFieldExpressionAndCancellationToken_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var token = new CancellationToken(true);
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync(keyedFieldExpression, token);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(keyedFieldExpression, null, null, token));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WithFieldExpressionAndOptions_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var indexName = Fixture.Create<string>();
|
||||
var options = new IndexCreationOptions { Name = indexName };
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync(keyedFieldExpression, options);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(
|
||||
keyedFieldExpression, options, null, CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WithFieldExpressionAndOptionsAndCancellationToken_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var indexName = Fixture.Create<string>();
|
||||
var options = new IndexCreationOptions { Name = indexName };
|
||||
var token = new CancellationToken(true);
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync(keyedFieldExpression, options, token);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(
|
||||
keyedFieldExpression, options, null, token));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WithFieldExpressionAndPartitionKey_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var partitionKey = Fixture.Create<string>();
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync(keyedFieldExpression, partitionKey);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(
|
||||
keyedFieldExpression, null, partitionKey, CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WithFieldExpressionAndPartitionKeyAndCancellationToken_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var partitionKey = Fixture.Create<string>();
|
||||
var token = new CancellationToken(true);
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync(keyedFieldExpression, partitionKey, token);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(
|
||||
keyedFieldExpression, null, partitionKey, token));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WithFieldExpressionAndOptionsAndPartitionKey_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var partitionKey = Fixture.Create<string>();
|
||||
var indexName = Fixture.Create<string>();
|
||||
var options = new IndexCreationOptions { Name = indexName };
|
||||
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync(keyedFieldExpression, options, partitionKey);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(
|
||||
keyedFieldExpression, options, partitionKey, CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WithFieldExpressionAndOptionsAndPartitionKeyAndCancellationToken_CreatesIndex()
|
||||
{
|
||||
// Arrange
|
||||
var partitionKey = Fixture.Create<string>();
|
||||
var token = new CancellationToken(true);
|
||||
var indexName = Fixture.Create<string>();
|
||||
var options = new IndexCreationOptions { Name = indexName };
|
||||
|
||||
IndexHandler = new Mock<IMongoDbIndexHandler>();
|
||||
|
||||
// Act
|
||||
await Sut.CreateHashedIndexAsync(keyedFieldExpression, options, partitionKey, token);
|
||||
|
||||
// Assert
|
||||
IndexHandler.Verify(
|
||||
x => x.CreateHashedIndexAsync<TestDocumentWithKey<int>, int>(
|
||||
keyedFieldExpression, options, partitionKey, token));
|
||||
}
|
||||
}
|
||||
@@ -522,24 +522,123 @@ namespace MongoDbGenericRepository
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<string> CreateHashedIndexAsync<TDocument>(
|
||||
Expression<Func<TDocument, object>> field,
|
||||
IndexCreationOptions indexCreationOptions = null,
|
||||
string partitionKey = null)
|
||||
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return await CreateHashedIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey);
|
||||
return await CreateHashedIndexAsync<TDocument, Guid>(field, null, null, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(
|
||||
Expression<Func<TDocument, object>> field,
|
||||
IndexCreationOptions indexCreationOptions = null,
|
||||
string partitionKey = null)
|
||||
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return await CreateHashedIndexAsync<TDocument, Guid>(field, null, null, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return await CreateHashedIndexAsync<TDocument, Guid>(field, indexCreationOptions, null, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return await CreateHashedIndexAsync<TDocument, Guid>(field, indexCreationOptions, null, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return await CreateHashedIndexAsync<TDocument, Guid>(field, null, partitionKey, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return await CreateHashedIndexAsync<TDocument, Guid>(field, null, partitionKey, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return await CreateHashedIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return await CreateHashedIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
return await MongoDbIndexHandler.CreateHashedIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
|
||||
return await CreateHashedIndexAsync<TDocument, TKey>(field, null, null, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
return await CreateHashedIndexAsync<TDocument, TKey>(field, null, null, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
return await CreateHashedIndexAsync<TDocument, TKey>(field, indexCreationOptions, null, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
return await CreateHashedIndexAsync<TDocument, TKey>(field, indexCreationOptions, null, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
return await CreateHashedIndexAsync<TDocument, TKey>(field, null, partitionKey, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
return await CreateHashedIndexAsync<TDocument, TKey>(field, null, partitionKey, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
return await CreateHashedIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
return await MongoDbIndexHandler.CreateHashedIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -404,6 +404,91 @@ namespace MongoDbGenericRepository
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a hashed index on the given field.
|
||||
/// 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> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a hashed index on the given field.
|
||||
/// 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> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a hashed index on the given field.
|
||||
/// 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> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a hashed index on the given field.
|
||||
/// 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> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a hashed index on the given field.
|
||||
/// 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> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a hashed index on the given field.
|
||||
/// 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> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a hashed index on the given field.
|
||||
/// IndexCreationOptions can be supplied to further specify
|
||||
@@ -415,7 +500,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> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
||||
Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a hashed index on the given field.
|
||||
/// 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> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>;
|
||||
|
||||
|
||||
@@ -284,10 +284,59 @@ namespace MongoDbGenericRepository
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field)
|
||||
where TDocument : IDocument<TKey>
|
||||
{
|
||||
return await MongoDbIndexHandler.CreateHashedIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey);
|
||||
return await CreateHashedIndexAsync(field, null, null, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>
|
||||
{
|
||||
return await CreateHashedIndexAsync(field, null, null, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
|
||||
where TDocument : IDocument<TKey>
|
||||
{
|
||||
return await CreateHashedIndexAsync(field, indexCreationOptions, null, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>
|
||||
{
|
||||
return await CreateHashedIndexAsync(field, indexCreationOptions, null, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey)
|
||||
where TDocument : IDocument<TKey>
|
||||
{
|
||||
return await CreateHashedIndexAsync(field, null, partitionKey, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>
|
||||
{
|
||||
return await CreateHashedIndexAsync(field, null, partitionKey, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
|
||||
where TDocument : IDocument<TKey>
|
||||
{
|
||||
return await CreateHashedIndexAsync(field, indexCreationOptions, partitionKey, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>
|
||||
{
|
||||
return await MongoDbIndexHandler.CreateHashedIndexAsync<TDocument, TKey>(field, indexCreationOptions, partitionKey, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -350,6 +350,79 @@ namespace MongoDbGenericRepository
|
||||
Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a hashed index on the given field.
|
||||
/// 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> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field)
|
||||
where TDocument : IDocument<TKey>;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a hashed index on the given field.
|
||||
/// 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> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a hashed index on the given field.
|
||||
/// 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> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions)
|
||||
where TDocument : IDocument<TKey>;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a hashed index on the given field.
|
||||
/// 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> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a hashed index on the given field.
|
||||
/// 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> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey)
|
||||
where TDocument : IDocument<TKey>;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a hashed index on the given field.
|
||||
/// 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> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, string partitionKey, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a hashed index on the given field.
|
||||
/// IndexCreationOptions can be supplied to further specify
|
||||
@@ -360,7 +433,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> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
|
||||
Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey)
|
||||
where TDocument : IDocument<TKey>;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a hashed index on the given field.
|
||||
/// 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> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions, string partitionKey, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>;
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user