added cancellation tokens to sync deletes and added more unit tests
This commit is contained in:
@@ -47,10 +47,9 @@ namespace MongoDbGenericRepository
|
||||
public virtual long DeleteOne<TDocument>(TDocument document, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return MongoDbEraser.DeleteOne<TDocument, Guid>(document, cancellationToken);
|
||||
return DeleteOne<TDocument, Guid>(document, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual long DeleteOne<TDocument>(Expression<Func<TDocument, bool>> filter)
|
||||
where TDocument : IDocument<Guid>
|
||||
@@ -76,7 +75,7 @@ namespace MongoDbGenericRepository
|
||||
public virtual long DeleteOne<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return MongoDbEraser.DeleteOne<TDocument, Guid>(filter, partitionKey, cancellationToken);
|
||||
return DeleteOne<TDocument, Guid>(filter, partitionKey, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -90,10 +89,9 @@ namespace MongoDbGenericRepository
|
||||
public virtual async Task<long> DeleteOneAsync<TDocument>(TDocument document, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return await MongoDbEraser.DeleteOneAsync<TDocument, Guid>(document, cancellationToken);
|
||||
return await DeleteOneAsync<TDocument, Guid>(document, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual async Task<long> DeleteOneAsync<TDocument>(Expression<Func<TDocument, bool>> filter)
|
||||
where TDocument : IDocument<Guid>
|
||||
@@ -119,7 +117,7 @@ namespace MongoDbGenericRepository
|
||||
public virtual async Task<long> DeleteOneAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return await MongoDbEraser.DeleteOneAsync<TDocument, Guid>(filter, partitionKey, cancellationToken);
|
||||
return await DeleteOneAsync<TDocument, Guid>(filter, partitionKey, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -147,7 +145,7 @@ namespace MongoDbGenericRepository
|
||||
public async Task<long> DeleteManyAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return await MongoDbEraser.DeleteManyAsync<TDocument, Guid>(filter, partitionKey, cancellationToken);
|
||||
return await DeleteManyAsync<TDocument, Guid>(filter, partitionKey, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -168,14 +166,42 @@ namespace MongoDbGenericRepository
|
||||
public virtual long DeleteMany<TDocument>(IEnumerable<TDocument> documents)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return DeleteMany<TDocument, Guid>(documents);
|
||||
return DeleteMany<TDocument, Guid>(documents, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual long DeleteMany<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null)
|
||||
public virtual long DeleteMany<TDocument>(IEnumerable<TDocument> documents, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return MongoDbEraser.DeleteMany<TDocument, Guid>(filter, partitionKey);
|
||||
return DeleteMany<TDocument, Guid>(documents, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual long DeleteMany<TDocument>(Expression<Func<TDocument, bool>> filter)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return DeleteMany(filter, null, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual long DeleteMany<TDocument>(Expression<Func<TDocument, bool>> filter, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return DeleteMany(filter, null, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual long DeleteMany<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return DeleteMany(filter, partitionKey, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual long DeleteMany<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<Guid>
|
||||
{
|
||||
return DeleteMany<TDocument, Guid>(filter, partitionKey, cancellationToken);
|
||||
}
|
||||
|
||||
#endregion Delete
|
||||
@@ -331,15 +357,47 @@ namespace MongoDbGenericRepository
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
return MongoDbEraser.DeleteMany<TDocument, TKey>(documents);
|
||||
return DeleteMany<TDocument, TKey>(documents, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual long DeleteMany<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null)
|
||||
public virtual long DeleteMany<TDocument, TKey>(IEnumerable<TDocument> documents, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
return MongoDbEraser.DeleteMany<TDocument, TKey>(filter, partitionKey);
|
||||
return MongoDbEraser.DeleteMany<TDocument, TKey>(documents, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual long DeleteMany<TDocument, TKey>(Expression<Func<TDocument, bool>> filter)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
return DeleteMany<TDocument, TKey>(filter, null, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual long DeleteMany<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
return DeleteMany<TDocument, TKey>(filter, null, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual long DeleteMany<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
return DeleteMany<TDocument, TKey>(filter, partitionKey, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual long DeleteMany<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey, CancellationToken cancellationToken)
|
||||
where TDocument : IDocument<TKey>
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
return MongoDbEraser.DeleteMany<TDocument, TKey>(filter, partitionKey, cancellationToken);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user