Compare commits

..

16 Commits

Author SHA1 Message Date
Alexandre SPIESER eebdc89575 adding cancellation token 2021-03-12 10:13:28 +00:00
Alexandre SPIESER ee4950c5d4 Merge branch 'master' into alex/UpdateMany 2021-03-10 08:45:10 +00:00
Alexandre SPIESER 658c753989 Added cancellation tokens (ongoing) 2021-03-10 08:44:50 +00:00
Alexandre SPIESER 0e8d629a8f Update README.md 2020-06-09 17:18:43 +01:00
Alexandre SPIESER ba3f876f95 Merge pull request #35 from alexandre-spieser/alex/UpdateMany
remove default option: IsUpset = true in update methods, to avoid une…
2020-06-09 09:02:31 +01:00
Alexandre SPIESER e4a36e5c60 remove default option: IsUpset = true in update methods, to avoid unexpected document insertions. 2020-06-09 09:01:53 +01:00
Alexandre SPIESER 592c30ed2c Merge pull request #34 from alexandre-spieser/alex/UpdateMany
Alex/update many
2020-06-06 12:16:58 +01:00
Alexandre SPIESER 83f1d2c7a6 nuget package works locally 2020-06-06 12:06:28 +01:00
Alexandre SPIESER ab294d1a5d remove ncrunch noise 2020-06-06 11:31:11 +01:00
Alexandre SPIESER dd8cbe3da7 Merge branch 'master' into alex/UpdateMany 2020-06-06 11:29:31 +01:00
Alexandre SPIESER 0844c51566 update many implementation, with tests 2020-06-06 11:28:46 +01:00
Alexandre SPIESER 601c0fd02d Update README.md 2020-06-06 08:31:35 +01:00
Alexandre SPIESER 91d15312e6 Update README.md 2020-06-05 07:26:28 +01:00
Alexandre SPIESER 54b2a63a8e Update README.md 2020-05-06 08:11:31 +01:00
Alexandre SPIESER dbb27aad39 Update README.md 2020-04-22 19:18:18 +01:00
Alexandre SPIESER afd0308849 Update README.md 2020-04-22 19:16:57 +01:00
34 changed files with 2754 additions and 12963 deletions
@@ -7,8 +7,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.1.2" /> <PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.1.2" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="2.1.2" /> <PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="2.1.2" />
<PackageReference Include="MongoDB.Driver" Version="2.9.3" /> <PackageReference Include="MongoDB.Driver" Version="2.12.0" />
<PackageReference Include="MongoDbGenericRepository" Version="1.4.3" />
<PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.console" Version="2.4.1"> <PackageReference Include="xunit.runner.console" Version="2.4.1">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
@@ -18,6 +17,10 @@
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta4-build3742" /> <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta4-build3742" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MongoDbGenericRepository\MongoDbGenericRepository.csproj" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System.Configuration"> <Reference Include="System.Configuration">
<HintPath>..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Configuration.dll</HintPath> <HintPath>..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Configuration.dll</HintPath>
@@ -12,7 +12,7 @@ using Xunit;
namespace CoreIntegrationTests.Infrastructure namespace CoreIntegrationTests.Infrastructure
{ {
public abstract class MongoDbDocumentTestBase<T> : public abstract partial class MongoDbDocumentTestBase<T> :
IClassFixture<MongoDbTestFixture<T, Guid>> IClassFixture<MongoDbTestFixture<T, Guid>>
where T : TestDoc, new() where T : TestDoc, new()
{ {
@@ -347,160 +347,6 @@ namespace CoreIntegrationTests.Infrastructure
#endregion Read #endregion Read
#region Update
[Fact]
public void UpdateOne()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T>(document);
var content = GetContent();
document.SomeContent = content;
// Act
var result = SUT.UpdateOne<T>(document);
// Assert
Assert.True(result);
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public async Task UpdateOneAsync()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T>(document);
var content = GetContent();
document.SomeContent = content;
// Act
var result = await SUT.UpdateOneAsync<T>(document);
// Assert
Assert.True(result);
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public void UpdateOneField()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T>(document);
var content = GetContent();
// Act
var result = SUT.UpdateOne<T, string>(document, x => x.SomeContent, content);
// Assert
Assert.True(result, GetTestName());
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public async Task UpdateOneFieldAsync()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T>(document);
var content = GetContent();
// Act
var result = await SUT.UpdateOneAsync<T, string>(document, x => x.SomeContent, content);
// Assert
Assert.True(result, GetTestName());
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public void UpdateOneFieldWithFilter()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T>(document);
var content = GetContent();
// Act
var result = SUT.UpdateOne<T, string>(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
// Assert
Assert.True(result, GetTestName());
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public async Task UpdateOneFieldWithFilterAsync()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T>(document);
var content = GetContent();
// Act
var result = await SUT.UpdateOneAsync<T, string>(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
// Assert
Assert.True(result, GetTestName());
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public async Task UpdateOneAsyncWithUpdateDefinition()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T>(document);
var childrenToAdd = new List<Child>
{
new Child("testType1", "testValue1"),
new Child("testType2", "testValue2")
};
var updateDef = MongoDB.Driver.Builders<T>.Update.AddToSetEach(p => p.Children, childrenToAdd);
// Act
var result = await SUT.UpdateOneAsync<T>(document, updateDef);
// Assert
Assert.True(result);
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.True(null != updatedDocument);
Assert.True(childrenToAdd[0].Type == updatedDocument.Children[0].Type, GetTestName());
Assert.True(childrenToAdd[0].Value == updatedDocument.Children[0].Value, GetTestName());
Assert.True(childrenToAdd[1].Type == updatedDocument.Children[1].Type, GetTestName());
Assert.True(childrenToAdd[1].Value == updatedDocument.Children[1].Value, GetTestName());
}
[Fact]
public void UpdateOneWithUpdateDefinition()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T>(document);
var childrenToAdd = new List<Child>
{
new Child("testType1", "testValue1"),
new Child("testType2", "testValue2")
};
var updateDef = MongoDB.Driver.Builders<T>.Update.AddToSetEach(p => p.Children, childrenToAdd);
// Act
var result = SUT.UpdateOne<T>(document, updateDef);
// Assert
Assert.True(result);
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.True(null != updatedDocument);
Assert.True(childrenToAdd[0].Type == updatedDocument.Children[0].Type, GetTestName());
Assert.True(childrenToAdd[0].Value == updatedDocument.Children[0].Value, GetTestName());
Assert.True(childrenToAdd[1].Type == updatedDocument.Children[1].Type, GetTestName());
Assert.True(childrenToAdd[1].Value == updatedDocument.Children[1].Value, GetTestName());
}
#endregion Update
#region Delete #region Delete
[Fact] [Fact]
@@ -0,0 +1,381 @@
using MongoDB.Driver;
using MongoDbGenericRepository;
using MongoDbGenericRepository.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
namespace CoreIntegrationTests.Infrastructure
{
public abstract partial class MongoDbDocumentTestBase<T> :
IClassFixture<MongoDbTestFixture<T, Guid>>
where T : TestDoc, new()
{
#region Update One
[Fact]
public void UpdateOne()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T>(document);
var content = GetContent();
document.SomeContent = content;
// Act
var result = SUT.UpdateOne<T>(document);
// Assert
Assert.True(result);
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public async Task UpdateOneAsync()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T>(document);
var content = GetContent();
document.SomeContent = content;
// Act
var result = await SUT.UpdateOneAsync<T>(document);
// Assert
Assert.True(result);
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public void UpdateOneField()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T>(document);
var content = GetContent();
// Act
var result = SUT.UpdateOne<T, string>(document, x => x.SomeContent, content);
// Assert
Assert.True(result, GetTestName());
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public async Task UpdateOneFieldAsync()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T>(document);
var content = GetContent();
// Act
var result = await SUT.UpdateOneAsync<T, string>(document, x => x.SomeContent, content);
// Assert
Assert.True(result, GetTestName());
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public void UpdateOneFieldWithFilter()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T>(document);
var content = GetContent();
// Act
var result = SUT.UpdateOne<T, string>(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
// Assert
Assert.True(result, GetTestName());
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public async Task UpdateOneFieldWithFilterAsync()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T>(document);
var content = GetContent();
// Act
var result = await SUT.UpdateOneAsync<T, string>(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
// Assert
Assert.True(result, GetTestName());
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public async Task UpdateOneAsyncWithUpdateDefinition()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T>(document);
var childrenToAdd = new List<Child>
{
new Child("testType1", "testValue1"),
new Child("testType2", "testValue2")
};
var updateDef = MongoDB.Driver.Builders<T>.Update.AddToSetEach(p => p.Children, childrenToAdd);
// Act
var result = await SUT.UpdateOneAsync<T>(document, updateDef);
// Assert
Assert.True(result);
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.True(null != updatedDocument);
Assert.True(childrenToAdd[0].Type == updatedDocument.Children[0].Type, GetTestName());
Assert.True(childrenToAdd[0].Value == updatedDocument.Children[0].Value, GetTestName());
Assert.True(childrenToAdd[1].Type == updatedDocument.Children[1].Type, GetTestName());
Assert.True(childrenToAdd[1].Value == updatedDocument.Children[1].Value, GetTestName());
}
[Fact]
public void UpdateOneWithUpdateDefinition()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T>(document);
var childrenToAdd = new List<Child>
{
new Child("testType1", "testValue1"),
new Child("testType2", "testValue2")
};
var updateDef = MongoDB.Driver.Builders<T>.Update.AddToSetEach(p => p.Children, childrenToAdd);
// Act
var result = SUT.UpdateOne<T>(document, updateDef);
// Assert
Assert.True(result);
var updatedDocument = SUT.GetById<T>(document.Id, PartitionKey);
Assert.True(null != updatedDocument);
Assert.True(childrenToAdd[0].Type == updatedDocument.Children[0].Type, GetTestName());
Assert.True(childrenToAdd[0].Value == updatedDocument.Children[0].Value, GetTestName());
Assert.True(childrenToAdd[1].Type == updatedDocument.Children[1].Type, GetTestName());
Assert.True(childrenToAdd[1].Value == updatedDocument.Children[1].Value, GetTestName());
}
#endregion Update One
#region Update Many
[Fact]
public async Task UpdateManyWithLinqFilterAsync()
{
// Arrange
var documents = CreateTestDocuments(2);
SUT.AddMany<T>(documents);
var docIds = documents.Select(u => u.Id).ToArray();
var content = GetContent();
// Act
var result = await SUT.UpdateManyAsync<T, string>(x => docIds.Contains(x.Id), x => x.SomeContent, content, PartitionKey);
// Assert
Assert.True(result == 2, GetTestName());
var updatedDocument = SUT.GetAll<T>(x => docIds.Contains(x.Id), PartitionKey);
Assert.True(updatedDocument.Count == 2);
Assert.True(updatedDocument.All(u => u.SomeContent == content), GetTestName());
}
[Fact]
public async Task UpdateManyWithFilterDefinitionAsync()
{
// Arrange
var documents = CreateTestDocuments(2);
SUT.AddMany<T>(documents);
var docIds = documents.Select(u => u.Id).ToArray();
var filterDefinition = Builders<T>.Filter.Where(x => docIds.Contains(x.Id));
var content = GetContent();
// Act
var result = await SUT.UpdateManyAsync<T, string>(filterDefinition, x => x.SomeContent, content, PartitionKey);
// Assert
Assert.True(result == 2, GetTestName());
var updatedDocument = SUT.GetAll<T>(x => docIds.Contains(x.Id), PartitionKey);
Assert.True(updatedDocument.Count == 2);
Assert.True(updatedDocument.All(u => u.SomeContent == content), GetTestName());
}
[Fact]
public async Task UpdateManyWithLinqFilterAndUpdateDefinitionAsync()
{
// Arrange
var documents = CreateTestDocuments(2);
SUT.AddMany<T>(documents);
var docIds = documents.Select(u => u.Id).ToArray();
var childrenToAdd = new List<Child>
{
new Child("testType1", "testValue1"),
new Child("testType2", "testValue2")
};
var updateDef = Builders<T>.Update.AddToSetEach(p => p.Children, childrenToAdd);
var content = GetContent();
// Act
var result = await SUT.UpdateManyAsync<T>(x => docIds.Contains(x.Id), updateDef, PartitionKey);
// Assert
Assert.True(result == 2, GetTestName());
var updatedDocuments = SUT.GetAll<T>(x => docIds.Contains(x.Id), PartitionKey);
Assert.True(updatedDocuments.Count == 2);
updatedDocuments.ForEach(updatedDocument =>
{
Assert.True(childrenToAdd[0].Type == updatedDocument.Children[0].Type, GetTestName());
Assert.True(childrenToAdd[0].Value == updatedDocument.Children[0].Value, GetTestName());
Assert.True(childrenToAdd[1].Type == updatedDocument.Children[1].Type, GetTestName());
Assert.True(childrenToAdd[1].Value == updatedDocument.Children[1].Value, GetTestName());
});
}
[Fact]
public async Task UpdateManyWithFilterAndUpdateDefinitionsAsync()
{
// Arrange
var documents = CreateTestDocuments(2);
SUT.AddMany<T>(documents);
var childrenToAdd = new List<Child>
{
new Child("testType1", "testValue1"),
new Child("testType2", "testValue2")
};
var updateDef = Builders<T>.Update.AddToSetEach(p => p.Children, childrenToAdd);
var docIds = documents.Select(u => u.Id).ToArray();
var filterDefinition = Builders<T>.Filter.Where(x => docIds.Contains(x.Id));
var content = GetContent();
// Act
var result = await SUT.UpdateManyAsync<T>(filterDefinition, updateDef, PartitionKey);
// Assert
Assert.True(result == 2, GetTestName());
var updatedDocuments = SUT.GetAll<T>(x => docIds.Contains(x.Id), PartitionKey);
Assert.True(updatedDocuments.Count == 2);
updatedDocuments.ForEach(updatedDocument =>
{
Assert.True(childrenToAdd[0].Type == updatedDocument.Children[0].Type, GetTestName());
Assert.True(childrenToAdd[0].Value == updatedDocument.Children[0].Value, GetTestName());
Assert.True(childrenToAdd[1].Type == updatedDocument.Children[1].Type, GetTestName());
Assert.True(childrenToAdd[1].Value == updatedDocument.Children[1].Value, GetTestName());
});
}
[Fact]
public void UpdateManyWithLinqFilter()
{
// Arrange
var documents = CreateTestDocuments(2);
SUT.AddMany<T>(documents);
var docIds = documents.Select(u => u.Id).ToArray();
var content = GetContent();
// Act
var result = SUT.UpdateMany<T, string>(x => docIds.Contains(x.Id), x => x.SomeContent, content, PartitionKey);
// Assert
Assert.True(result == 2, GetTestName());
var updatedDocument = SUT.GetAll<T>(x => docIds.Contains(x.Id), PartitionKey);
Assert.True(updatedDocument.Count == 2);
Assert.True(updatedDocument.All(u => u.SomeContent == content), GetTestName());
}
[Fact]
public void UpdateManyWithFilterDefinition()
{
// Arrange
var documents = CreateTestDocuments(2);
SUT.AddMany<T>(documents);
var docIds = documents.Select(u => u.Id).ToArray();
var filterDefinition = Builders<T>.Filter.Where(x => docIds.Contains(x.Id));
var content = GetContent();
// Act
var result = SUT.UpdateMany<T, string>(filterDefinition, x => x.SomeContent, content, PartitionKey);
// Assert
Assert.True(result == 2, GetTestName());
var updatedDocument = SUT.GetAll<T>(x => docIds.Contains(x.Id), PartitionKey);
Assert.True(updatedDocument.Count == 2);
Assert.True(updatedDocument.All(u => u.SomeContent == content), GetTestName());
}
[Fact]
public void UpdateManyWithLinqFilterAndUpdateDefinition()
{
// Arrange
var documents = CreateTestDocuments(2);
SUT.AddMany<T>(documents);
var docIds = documents.Select(u => u.Id).ToArray();
var childrenToAdd = new List<Child>
{
new Child("testType1", "testValue1"),
new Child("testType2", "testValue2")
};
var updateDef = Builders<T>.Update.AddToSetEach(p => p.Children, childrenToAdd);
var content = GetContent();
// Act
var result = SUT.UpdateMany<T>(x => docIds.Contains(x.Id), updateDef, PartitionKey);
// Assert
Assert.True(result == 2, GetTestName());
var updatedDocuments = SUT.GetAll<T>(x => docIds.Contains(x.Id), PartitionKey);
Assert.True(updatedDocuments.Count == 2);
updatedDocuments.ForEach(updatedDocument =>
{
Assert.True(childrenToAdd[0].Type == updatedDocument.Children[0].Type, GetTestName());
Assert.True(childrenToAdd[0].Value == updatedDocument.Children[0].Value, GetTestName());
Assert.True(childrenToAdd[1].Type == updatedDocument.Children[1].Type, GetTestName());
Assert.True(childrenToAdd[1].Value == updatedDocument.Children[1].Value, GetTestName());
});
}
[Fact]
public void UpdateManyWithFilterAndUpdateDefinitions()
{
// Arrange
var documents = CreateTestDocuments(2);
SUT.AddMany<T>(documents);
var childrenToAdd = new List<Child>
{
new Child("testType1", "testValue1"),
new Child("testType2", "testValue2")
};
var updateDef = Builders<T>.Update.AddToSetEach(p => p.Children, childrenToAdd);
var docIds = documents.Select(u => u.Id).ToArray();
var filterDefinition = Builders<T>.Filter.Where(x => docIds.Contains(x.Id));
var content = GetContent();
// Act
var result = SUT.UpdateMany<T>(filterDefinition, updateDef, PartitionKey);
// Assert
Assert.True(result == 2, GetTestName());
var updatedDocuments = SUT.GetAll<T>(x => docIds.Contains(x.Id), PartitionKey);
Assert.True(updatedDocuments.Count == 2);
updatedDocuments.ForEach(updatedDocument =>
{
Assert.True(childrenToAdd[0].Type == updatedDocument.Children[0].Type, GetTestName());
Assert.True(childrenToAdd[0].Value == updatedDocument.Children[0].Value, GetTestName());
Assert.True(childrenToAdd[1].Type == updatedDocument.Children[1].Type, GetTestName());
Assert.True(childrenToAdd[1].Value == updatedDocument.Children[1].Value, GetTestName());
});
}
#endregion Update Many
}
}
@@ -12,7 +12,7 @@ using Xunit;
namespace CoreIntegrationTests.Infrastructure namespace CoreIntegrationTests.Infrastructure
{ {
public abstract class MongoDbTKeyDocumentTestBase<T, TKey> : public abstract partial class MongoDbTKeyDocumentTestBase<T, TKey> :
IClassFixture<MongoDbTestFixture<T, TKey>> IClassFixture<MongoDbTestFixture<T, TKey>>
where T : TestDoc<TKey>, new() where T : TestDoc<TKey>, new()
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
@@ -348,160 +348,6 @@ namespace CoreIntegrationTests.Infrastructure
#endregion Read #endregion Read
#region Update
[Fact]
public void UpdateOne()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T, TKey>(document);
var content = GetContent();
document.SomeContent = content;
// Act
var result = SUT.UpdateOne<T, TKey>(document);
// Assert
Assert.True(result);
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public async Task UpdateOneAsync()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T, TKey>(document);
var content = GetContent();
document.SomeContent = content;
// Act
var result = await SUT.UpdateOneAsync<T, TKey>(document);
// Assert
Assert.True(result);
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public void UpdateOneField()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T, TKey>(document);
var content = GetContent();
// Act
var result = SUT.UpdateOne<T, TKey, string>(document, x => x.SomeContent, content);
// Assert
Assert.True(result, GetTestName());
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public async Task UpdateOneFieldAsync()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T, TKey>(document);
var content = GetContent();
// Act
var result = await SUT.UpdateOneAsync<T, TKey, string>(document, x => x.SomeContent, content);
// Assert
Assert.True(result, GetTestName());
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public void UpdateOneFieldWithFilter()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T, TKey>(document);
var content = GetContent();
// Act
var result = SUT.UpdateOne<T, TKey, string>(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
// Assert
Assert.True(result, GetTestName());
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public async Task UpdateOneFieldWithFilterAsync()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T, TKey>(document);
var content = GetContent();
// Act
var result = await SUT.UpdateOneAsync<T, TKey, string>(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
// Assert
Assert.True(result, GetTestName());
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public async Task UpdateOneAsyncWithUpdateDefinition()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T, TKey>(document);
var childrenToAdd = new List<Child>
{
new Child("testType1", "testValue1"),
new Child("testType2", "testValue2")
};
var updateDef = MongoDB.Driver.Builders<T>.Update.AddToSetEach(p => p.Children, childrenToAdd);
// Act
var result = await SUT.UpdateOneAsync<T, TKey>(document, updateDef);
// Assert
Assert.True(result);
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.True(null != updatedDocument);
Assert.True(childrenToAdd[0].Type == updatedDocument.Children[0].Type, GetTestName());
Assert.True(childrenToAdd[0].Value == updatedDocument.Children[0].Value, GetTestName());
Assert.True(childrenToAdd[1].Type == updatedDocument.Children[1].Type, GetTestName());
Assert.True(childrenToAdd[1].Value == updatedDocument.Children[1].Value, GetTestName());
}
[Fact]
public void UpdateOneWithUpdateDefinition()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T, TKey>(document);
var childrenToAdd = new List<Child>
{
new Child("testType1", "testValue1"),
new Child("testType2", "testValue2")
};
var updateDef = MongoDB.Driver.Builders<T>.Update.AddToSetEach(p => p.Children, childrenToAdd);
// Act
var result = SUT.UpdateOne<T, TKey>(document, updateDef);
// Assert
Assert.True(result);
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.True(null != updatedDocument);
Assert.True(childrenToAdd[0].Type == updatedDocument.Children[0].Type, GetTestName());
Assert.True(childrenToAdd[0].Value == updatedDocument.Children[0].Value, GetTestName());
Assert.True(childrenToAdd[1].Type == updatedDocument.Children[1].Type, GetTestName());
Assert.True(childrenToAdd[1].Value == updatedDocument.Children[1].Value, GetTestName());
}
#endregion Update
#region Delete #region Delete
[Fact] [Fact]
@@ -0,0 +1,377 @@
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
namespace CoreIntegrationTests.Infrastructure
{
public abstract partial class MongoDbTKeyDocumentTestBase<T, TKey> :
IClassFixture<MongoDbTestFixture<T, TKey>>
where T : TestDoc<TKey>, new()
where TKey : IEquatable<TKey>
{
#region Update One
[Fact]
public void UpdateOne()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T, TKey>(document);
var content = GetContent();
document.SomeContent = content;
// Act
var result = SUT.UpdateOne<T, TKey>(document);
// Assert
Assert.True(result);
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public async Task UpdateOneAsync()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T, TKey>(document);
var content = GetContent();
document.SomeContent = content;
// Act
var result = await SUT.UpdateOneAsync<T, TKey>(document);
// Assert
Assert.True(result);
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public void UpdateOneField()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T, TKey>(document);
var content = GetContent();
// Act
var result = SUT.UpdateOne<T, TKey, string>(document, x => x.SomeContent, content);
// Assert
Assert.True(result, GetTestName());
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public async Task UpdateOneFieldAsync()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T, TKey>(document);
var content = GetContent();
// Act
var result = await SUT.UpdateOneAsync<T, TKey, string>(document, x => x.SomeContent, content);
// Assert
Assert.True(result, GetTestName());
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public void UpdateOneFieldWithFilter()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T, TKey>(document);
var content = GetContent();
// Act
var result = SUT.UpdateOne<T, TKey, string>(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
// Assert
Assert.True(result, GetTestName());
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public async Task UpdateOneFieldWithFilterAsync()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T, TKey>(document);
var content = GetContent();
// Act
var result = await SUT.UpdateOneAsync<T, TKey, string>(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
// Assert
Assert.True(result, GetTestName());
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.True(null != updatedDocument, GetTestName());
Assert.True(content == updatedDocument.SomeContent, GetTestName());
}
[Fact]
public async Task UpdateOneAsyncWithUpdateDefinition()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T, TKey>(document);
var childrenToAdd = new List<Child>
{
new Child("testType1", "testValue1"),
new Child("testType2", "testValue2")
};
var updateDef = MongoDB.Driver.Builders<T>.Update.AddToSetEach(p => p.Children, childrenToAdd);
// Act
var result = await SUT.UpdateOneAsync<T, TKey>(document, updateDef);
// Assert
Assert.True(result);
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.True(null != updatedDocument);
Assert.True(childrenToAdd[0].Type == updatedDocument.Children[0].Type, GetTestName());
Assert.True(childrenToAdd[0].Value == updatedDocument.Children[0].Value, GetTestName());
Assert.True(childrenToAdd[1].Type == updatedDocument.Children[1].Type, GetTestName());
Assert.True(childrenToAdd[1].Value == updatedDocument.Children[1].Value, GetTestName());
}
[Fact]
public void UpdateOneWithUpdateDefinition()
{
// Arrange
var document = CreateTestDocument();
SUT.AddOne<T, TKey>(document);
var childrenToAdd = new List<Child>
{
new Child("testType1", "testValue1"),
new Child("testType2", "testValue2")
};
var updateDef = MongoDB.Driver.Builders<T>.Update.AddToSetEach(p => p.Children, childrenToAdd);
// Act
var result = SUT.UpdateOne<T, TKey>(document, updateDef);
// Assert
Assert.True(result);
var updatedDocument = SUT.GetById<T, TKey>(document.Id, PartitionKey);
Assert.True(null != updatedDocument);
Assert.True(childrenToAdd[0].Type == updatedDocument.Children[0].Type, GetTestName());
Assert.True(childrenToAdd[0].Value == updatedDocument.Children[0].Value, GetTestName());
Assert.True(childrenToAdd[1].Type == updatedDocument.Children[1].Type, GetTestName());
Assert.True(childrenToAdd[1].Value == updatedDocument.Children[1].Value, GetTestName());
}
#endregion Update One
#region Update Many
[Fact]
public async Task UpdateManyWithLinqFilterAsync()
{
// Arrange
var documents = CreateTestDocuments(2);
SUT.AddMany<T, TKey>(documents);
var docIds = documents.Select(u => u.Id).ToArray();
var content = GetContent();
// Act
var result = await SUT.UpdateManyAsync<T, TKey, string>(x => docIds.Contains(x.Id), x => x.SomeContent, content, PartitionKey);
// Assert
Assert.True(result == 2, GetTestName());
var updatedDocument = SUT.GetAll<T, TKey>(x => docIds.Contains(x.Id), PartitionKey);
Assert.True(updatedDocument.Count == 2);
Assert.True(updatedDocument.All(u => u.SomeContent == content), GetTestName());
}
[Fact]
public async Task UpdateManyWithFilterDefinitionAsync()
{
// Arrange
var documents = CreateTestDocuments(2);
SUT.AddMany<T, TKey>(documents);
var docIds = documents.Select(u => u.Id).ToArray();
var filterDefinition = Builders<T>.Filter.Where(x => docIds.Contains(x.Id));
var content = GetContent();
// Act
var result = await SUT.UpdateManyAsync<T, TKey, string>(filterDefinition, x => x.SomeContent, content, PartitionKey);
// Assert
Assert.True(result == 2, GetTestName());
var updatedDocument = SUT.GetAll<T, TKey>(x => docIds.Contains(x.Id), PartitionKey);
Assert.True(updatedDocument.Count == 2);
Assert.True(updatedDocument.All(u => u.SomeContent == content), GetTestName());
}
[Fact]
public async Task UpdateManyWithLinqFilterAndUpdateDefinitionAsync()
{
// Arrange
var documents = CreateTestDocuments(2);
SUT.AddMany<T, TKey>(documents);
var docIds = documents.Select(u => u.Id).ToArray();
var childrenToAdd = new List<Child>
{
new Child("testType1", "testValue1"),
new Child("testType2", "testValue2")
};
var updateDef = Builders<T>.Update.AddToSetEach(p => p.Children, childrenToAdd);
var content = GetContent();
// Act
var result = await SUT.UpdateManyAsync<T, TKey>(x => docIds.Contains(x.Id), updateDef, PartitionKey);
// Assert
Assert.True(result == 2, GetTestName());
var updatedDocuments = SUT.GetAll<T, TKey>(x => docIds.Contains(x.Id), PartitionKey);
Assert.True(updatedDocuments.Count == 2);
updatedDocuments.ForEach(updatedDocument =>
{
Assert.True(childrenToAdd[0].Type == updatedDocument.Children[0].Type, GetTestName());
Assert.True(childrenToAdd[0].Value == updatedDocument.Children[0].Value, GetTestName());
Assert.True(childrenToAdd[1].Type == updatedDocument.Children[1].Type, GetTestName());
Assert.True(childrenToAdd[1].Value == updatedDocument.Children[1].Value, GetTestName());
});
}
[Fact]
public async Task UpdateManyWithFilterAndUpdateDefinitionsAsync()
{
// Arrange
var documents = CreateTestDocuments(2);
SUT.AddMany<T, TKey>(documents);
var childrenToAdd = new List<Child>
{
new Child("testType1", "testValue1"),
new Child("testType2", "testValue2")
};
var updateDef = Builders<T>.Update.AddToSetEach(p => p.Children, childrenToAdd);
var docIds = documents.Select(u => u.Id).ToArray();
var filterDefinition = Builders<T>.Filter.Where(x => docIds.Contains(x.Id));
var content = GetContent();
// Act
var result = await SUT.UpdateManyAsync<T, TKey>(filterDefinition, updateDef, PartitionKey);
// Assert
Assert.True(result == 2, GetTestName());
var updatedDocuments = SUT.GetAll<T, TKey>(x => docIds.Contains(x.Id), PartitionKey);
Assert.True(updatedDocuments.Count == 2);
updatedDocuments.ForEach(updatedDocument =>
{
Assert.True(childrenToAdd[0].Type == updatedDocument.Children[0].Type, GetTestName());
Assert.True(childrenToAdd[0].Value == updatedDocument.Children[0].Value, GetTestName());
Assert.True(childrenToAdd[1].Type == updatedDocument.Children[1].Type, GetTestName());
Assert.True(childrenToAdd[1].Value == updatedDocument.Children[1].Value, GetTestName());
});
}
[Fact]
public void UpdateManyWithLinqFilter()
{
// Arrange
var documents = CreateTestDocuments(2);
SUT.AddMany<T, TKey>(documents);
var docIds = documents.Select(u => u.Id).ToArray();
var content = GetContent();
// Act
var result = SUT.UpdateMany<T, TKey, string>(x => docIds.Contains(x.Id), x => x.SomeContent, content, PartitionKey);
// Assert
Assert.True(result == 2, GetTestName());
var updatedDocument = SUT.GetAll<T, TKey>(x => docIds.Contains(x.Id), PartitionKey);
Assert.True(updatedDocument.Count == 2);
Assert.True(updatedDocument.All(u => u.SomeContent == content), GetTestName());
}
[Fact]
public void UpdateManyWithFilterDefinition()
{
// Arrange
var documents = CreateTestDocuments(2);
SUT.AddMany<T, TKey>(documents);
var docIds = documents.Select(u => u.Id).ToArray();
var filterDefinition = Builders<T>.Filter.Where(x => docIds.Contains(x.Id));
var content = GetContent();
// Act
var result = SUT.UpdateMany<T, TKey, string>(filterDefinition, x => x.SomeContent, content, PartitionKey);
// Assert
Assert.True(result == 2, GetTestName());
var updatedDocument = SUT.GetAll<T, TKey>(x => docIds.Contains(x.Id), PartitionKey);
Assert.True(updatedDocument.Count == 2);
Assert.True(updatedDocument.All(u => u.SomeContent == content), GetTestName());
}
[Fact]
public void UpdateManyWithLinqFilterAndUpdateDefinition()
{
// Arrange
var documents = CreateTestDocuments(2);
SUT.AddMany<T, TKey>(documents);
var docIds = documents.Select(u => u.Id).ToArray();
var childrenToAdd = new List<Child>
{
new Child("testType1", "testValue1"),
new Child("testType2", "testValue2")
};
var updateDef = Builders<T>.Update.AddToSetEach(p => p.Children, childrenToAdd);
var content = GetContent();
// Act
var result = SUT.UpdateMany<T, TKey>(x => docIds.Contains(x.Id), updateDef, PartitionKey);
// Assert
Assert.True(result == 2, GetTestName());
var updatedDocuments = SUT.GetAll<T, TKey>(x => docIds.Contains(x.Id), PartitionKey);
Assert.True(updatedDocuments.Count == 2);
updatedDocuments.ForEach(updatedDocument =>
{
Assert.True(childrenToAdd[0].Type == updatedDocument.Children[0].Type, GetTestName());
Assert.True(childrenToAdd[0].Value == updatedDocument.Children[0].Value, GetTestName());
Assert.True(childrenToAdd[1].Type == updatedDocument.Children[1].Type, GetTestName());
Assert.True(childrenToAdd[1].Value == updatedDocument.Children[1].Value, GetTestName());
});
}
[Fact]
public void UpdateManyWithFilterAndUpdateDefinitions()
{
// Arrange
var documents = CreateTestDocuments(2);
SUT.AddMany<T, TKey>(documents);
var childrenToAdd = new List<Child>
{
new Child("testType1", "testValue1"),
new Child("testType2", "testValue2")
};
var updateDef = Builders<T>.Update.AddToSetEach(p => p.Children, childrenToAdd);
var docIds = documents.Select(u => u.Id).ToArray();
var filterDefinition = Builders<T>.Filter.Where(x => docIds.Contains(x.Id));
var content = GetContent();
// Act
var result = SUT.UpdateMany<T, TKey>(filterDefinition, updateDef, PartitionKey);
// Assert
Assert.True(result == 2, GetTestName());
var updatedDocuments = SUT.GetAll<T, TKey>(x => docIds.Contains(x.Id), PartitionKey);
Assert.True(updatedDocuments.Count == 2);
updatedDocuments.ForEach(updatedDocument =>
{
Assert.True(childrenToAdd[0].Type == updatedDocument.Children[0].Type, GetTestName());
Assert.True(childrenToAdd[0].Value == updatedDocument.Children[0].Value, GetTestName());
Assert.True(childrenToAdd[1].Type == updatedDocument.Children[1].Type, GetTestName());
Assert.True(childrenToAdd[1].Value == updatedDocument.Children[1].Value, GetTestName());
});
}
#endregion Update Many
}
}
+2 -2
View File
@@ -49,8 +49,8 @@
<Reference Include="MongoDB.Driver.Core, Version=2.9.3.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="MongoDB.Driver.Core, Version=2.9.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDB.Driver.Core.2.9.3\lib\net452\MongoDB.Driver.Core.dll</HintPath> <HintPath>..\packages\MongoDB.Driver.Core.2.9.3\lib\net452\MongoDB.Driver.Core.dll</HintPath>
</Reference> </Reference>
<Reference Include="MongoDbGenericRepository, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="MongoDbGenericRepository, Version=1.4.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.4.3\lib\net452\MongoDbGenericRepository.dll</HintPath> <HintPath>..\packages\MongoDbGenericRepository.1.4.5\lib\net452\MongoDbGenericRepository.dll</HintPath>
</Reference> </Reference>
<Reference Include="nunit.framework, Version=3.12.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL"> <Reference Include="nunit.framework, Version=3.12.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll</HintPath> <HintPath>..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll</HintPath>
+1 -1
View File
@@ -5,7 +5,7 @@
<package id="MongoDB.Bson" version="2.9.3" targetFramework="net461" /> <package id="MongoDB.Bson" version="2.9.3" targetFramework="net461" />
<package id="MongoDB.Driver" version="2.9.3" targetFramework="net461" /> <package id="MongoDB.Driver" version="2.9.3" targetFramework="net461" />
<package id="MongoDB.Driver.Core" version="2.9.3" targetFramework="net461" /> <package id="MongoDB.Driver.Core" version="2.9.3" targetFramework="net461" />
<package id="MongoDbGenericRepository" version="1.4.3" targetFramework="net461" /> <package id="MongoDbGenericRepository" version="1.4.5" targetFramework="net461" />
<package id="NUnit" version="3.12.0" targetFramework="net461" /> <package id="NUnit" version="3.12.0" targetFramework="net461" />
<package id="NUnit.ConsoleRunner" version="3.10.0" targetFramework="net461" /> <package id="NUnit.ConsoleRunner" version="3.10.0" targetFramework="net461" />
<package id="NUnit3TestAdapter" version="3.15.1" targetFramework="net461" /> <package id="NUnit3TestAdapter" version="3.15.1" targetFramework="net461" />
@@ -1,5 +0,0 @@
<SolutionConfiguration>
<Settings>
<CurrentEngineMode>Run all tests automatically [Global]</CurrentEngineMode>
</Settings>
</SolutionConfiguration>
@@ -6,6 +6,9 @@ using System.Threading.Tasks;
namespace MongoDbGenericRepository namespace MongoDbGenericRepository
{ {
/// <summary>
/// The IBaseMongoRepository_Update interface exposing update functionality for documents with Guid Ids.
/// </summary>
public interface IBaseMongoRepository_Update : IBaseMongoRepository_Update<Guid> public interface IBaseMongoRepository_Update : IBaseMongoRepository_Update<Guid>
{ {
/// <summary> /// <summary>
@@ -131,5 +134,109 @@ namespace MongoDbGenericRepository
bool UpdateOne<TDocument, TKey, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null) bool UpdateOne<TDocument, TKey, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
Task<long> UpdateManyAsync<TDocument, TKey, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
Task<long> UpdateManyAsync<TDocument, TKey, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
Task<long> UpdateManyAsync<TDocument, TKey>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
Task<long> UpdateManyAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
long UpdateMany<TDocument, TKey, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
long UpdateMany<TDocument, TKey, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
long UpdateMany<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
long UpdateMany<TDocument, TKey>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
} }
} }
@@ -7,6 +7,9 @@ using MongoDbGenericRepository.Models;
namespace MongoDbGenericRepository.DataAccess.Update namespace MongoDbGenericRepository.DataAccess.Update
{ {
/// <summary>
/// The IBaseMongoRepository_Update_ClientSession interface exposing update functionality with a IClientSessionHandle.
/// </summary>
public interface IBaseMongoRepository_Update_ClientSession public interface IBaseMongoRepository_Update_ClientSession
{ {
/// <summary> /// <summary>
@@ -14,10 +17,14 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// </summary> /// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param> /// <param name="session">The client session.</param>
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param> /// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns> /// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -27,42 +34,18 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// </summary> /// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param> /// <param name="session">The client session.</param>
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param> /// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns> /// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </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="session">The client session.</param>
/// <param name="documentToModify">The document to modify.</param>
/// <param name="update">The update definition.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns>
bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </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="session">The client session.</param>
/// <param name="documentToModify">The document to modify.</param>
/// <param name="update">The update definition.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns>
bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary> /// <summary>
/// Updates a document. /// Updates a document.
/// </summary> /// </summary>
@@ -74,7 +57,34 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// <param name="field">The field to update.</param> /// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param> /// <param name="value">The value of the field.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns> /// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </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="session">The client session.</param>
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Updates a document.
/// </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="session">The client session.</param>
/// <param name="documentToModify">The document to modify.</param>
/// <param name="update">The update definition.</param>
/// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns>A boolean value indicating success.</returns>
bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken = default(CancellationToken)) bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -86,11 +96,12 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam> /// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param> /// <param name="session">The client session.</param>
/// <param name="documentToModify">The document to modify.</param> /// <param name="filter">The filter for the update.</param>
/// <param name="field">The field to update.</param> /// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param> /// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns> /// <returns>A boolean value indicating success.</returns>
Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -119,12 +130,11 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam> /// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param> /// <param name="session">The client session.</param>
/// <param name="filter">The filter for the update.</param> /// <param name="documentToModify">The document to modify.</param>
/// <param name="field">The field to update.</param> /// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param> /// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns> /// <returns>A boolean value indicating success.</returns>
Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken = default(CancellationToken)) Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -134,14 +144,10 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// </summary> /// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param> /// <param name="session">The client session.</param>
/// <param name="filter">The filter for the update.</param> /// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
/// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns> /// <returns>A boolean value indicating success.</returns>
Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken)) Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -151,14 +157,11 @@ namespace MongoDbGenericRepository.DataAccess.Update
/// </summary> /// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field to update.</typeparam>
/// <param name="session">The client session.</param> /// <param name="session">The client session.</param>
/// <param name="filter">The filter for the update.</param> /// <param name="documentToModify">The document to modify.</param>
/// <param name="field">The field to update.</param> /// <param name="update">The update definition.</param>
/// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns> /// <returns>A boolean value indicating success.</returns>
Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken = default(CancellationToken)) Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace MongoDbGenericRepository namespace MongoDbGenericRepository
@@ -32,7 +33,8 @@ namespace MongoDbGenericRepository
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="id">The Id of the document you want to get.</param> /// <param name="id">The Id of the document you want to get.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
Task<TDocument> GetByIdAsync<TDocument, TKey>(TKey id, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
Task<TDocument> GetByIdAsync<TDocument, TKey>(TKey id, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -54,7 +56,8 @@ namespace MongoDbGenericRepository
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
Task<TDocument> GetOneAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
Task<TDocument> GetOneAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -88,7 +91,8 @@ namespace MongoDbGenericRepository
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
Task<bool> AnyAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
Task<bool> AnyAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -110,7 +114,8 @@ namespace MongoDbGenericRepository
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
Task<List<TDocument>> GetAllAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
Task<List<TDocument>> GetAllAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -132,7 +137,8 @@ namespace MongoDbGenericRepository
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="partitionKey">An optional partitionKey</param> /// <param name="partitionKey">An optional partitionKey</param>
Task<long> CountAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
Task<long> CountAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -157,9 +163,13 @@ namespace MongoDbGenericRepository
/// <typeparam name="TDocument">The document type.</typeparam> /// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam> /// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="orderByDescending">A property selector to order by descending.</param> /// <param name="maxValueSelector">A property selector to order by descending.</param>
/// <param name="partitionKey">An optional partitionKey.</param> /// <param name="partitionKey">An optional partitionKey.</param>
Task<TDocument> GetByMaxAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> orderByDescending, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
Task<TDocument> GetByMaxAsync<TDocument, TKey>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, object>> maxValueSelector,
string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -181,9 +191,13 @@ namespace MongoDbGenericRepository
/// <typeparam name="TDocument">The document type.</typeparam> /// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam> /// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="orderByAscending">A property selector to order by ascending.</param> /// <param name="minValueSelector">A property selector for the minimum value you are looking for.</param>
/// <param name="partitionKey">An optional partitionKey.</param> /// <param name="partitionKey">An optional partitionKey.</param>
Task<TDocument> GetByMinAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> orderByAscending, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
Task<TDocument> GetByMinAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, object>> minValueSelector,
string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -193,9 +207,9 @@ namespace MongoDbGenericRepository
/// <typeparam name="TDocument">The document type.</typeparam> /// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam> /// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="orderByAscending">A property selector to order by ascending.</param> /// <param name="minValueSelector">A property selector for the minimum value you are looking for.</param>
/// <param name="partitionKey">An optional partitionKey.</param> /// <param name="partitionKey">An optional partitionKey.</param>
TDocument GetByMin<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> orderByAscending, string partitionKey = null) TDocument GetByMin<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> minValueSelector, string partitionKey = null)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -206,9 +220,14 @@ namespace MongoDbGenericRepository
/// <typeparam name="TKey">The type of the primary key.</typeparam> /// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <typeparam name="TValue">The type of the value used to order the query.</typeparam> /// <typeparam name="TValue">The type of the value used to order the query.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="orderByAscending">A property selector to order by ascending.</param> /// <param name="maxValueSelector">A property selector for the maximum value you are looking for.</param>
/// <param name="partitionKey">An optional partitionKey.</param> /// <param name="partitionKey">An optional partitionKey.</param>
Task<TValue> GetMaxValueAsync<TDocument, TKey, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> orderByAscending, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
Task<TValue> GetMaxValueAsync<TDocument, TKey, TValue>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TValue>> maxValueSelector,
string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -219,9 +238,9 @@ namespace MongoDbGenericRepository
/// <typeparam name="TKey">The type of the primary key.</typeparam> /// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <typeparam name="TValue">The type of the value used to order the query.</typeparam> /// <typeparam name="TValue">The type of the value used to order the query.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="orderByDescending">A property selector to order by ascending.</param> /// <param name="maxValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partitionKey.</param> /// <param name="partitionKey">An optional partitionKey.</param>
TValue GetMaxValue<TDocument, TKey, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> orderByDescending, string partitionKey = null) TValue GetMaxValue<TDocument, TKey, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> maxValueSelector, string partitionKey = null)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -234,7 +253,12 @@ namespace MongoDbGenericRepository
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="minValueSelector">A property selector to order by ascending.</param> /// <param name="minValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
Task<TValue> GetMinValueAsync<TDocument, TKey, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> minValueSelector, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
Task<TValue> GetMinValueAsync<TDocument, TKey, TValue>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TValue>> minValueSelector,
string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -263,9 +287,11 @@ namespace MongoDbGenericRepository
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="selector">The field you want to sum.</param> /// <param name="selector">The field you want to sum.</param>
/// <param name="partitionKey">The partition key of your document, if any.</param> /// <param name="partitionKey">The partition key of your document, if any.</param>
/// <param name="cancellationToken">An optional cancellation Token.</param>
Task<int> SumByAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Task<int> SumByAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, int>> selector, Expression<Func<TDocument, int>> selector,
string partitionKey = null) string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -321,10 +347,15 @@ namespace MongoDbGenericRepository
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam> /// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam>
/// <param name="filter"></param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="projection">The projection expression.</param> /// <param name="projection">The projection expression.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
Task<TProjection> ProjectOneAsync<TDocument, TProjection, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TProjection>> projection, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
Task<TProjection> ProjectOneAsync<TDocument, TProjection, TKey>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TProjection>> projection,
string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
where TProjection : class; where TProjection : class;
@@ -349,10 +380,15 @@ namespace MongoDbGenericRepository
/// <typeparam name="TDocument">The type representing a Document.</typeparam> /// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam> /// <typeparam name="TProjection">The type representing the model you want to project to.</typeparam>
/// <param name="filter"></param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="projection">The projection expression.</param> /// <param name="projection">The projection expression.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
Task<List<TProjection>> ProjectManyAsync<TDocument, TProjection, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TProjection>> projection, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
Task<List<TProjection>> ProjectManyAsync<TDocument, TProjection, TKey>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TProjection>> projection,
string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
where TProjection : class; where TProjection : class;
@@ -450,12 +486,14 @@ namespace MongoDbGenericRepository
/// <param name="skipNumber">The number of documents you want to skip. Default value is 0.</param> /// <param name="skipNumber">The number of documents you want to skip. Default value is 0.</param>
/// <param name="takeNumber">The number of documents you want to take. Default value is 50.</param> /// <param name="takeNumber">The number of documents you want to take. Default value is 50.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
/// <param name="cancellationToken">An optional cancellation Token.</param>
Task<List<TDocument>> GetSortedPaginatedAsync<TDocument, TKey>( Task<List<TDocument>> GetSortedPaginatedAsync<TDocument, TKey>(
Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, bool>> filter,
SortDefinition<TDocument> sortDefinition, SortDefinition<TDocument> sortDefinition,
int skipNumber = 0, int skipNumber = 0,
int takeNumber = 50, int takeNumber = 50,
string partitionKey = null) string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>; where TKey : IEquatable<TKey>;
@@ -18,7 +18,7 @@ namespace MongoDbGenericRepository
/// <param name="session">The client session.</param> /// <param name="session">The client session.</param>
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param> /// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns> /// <returns>A boolean value indicating success.</returns>
public virtual async Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken)) public virtual async Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
@@ -34,7 +34,7 @@ namespace MongoDbGenericRepository
/// <param name="session">The client session.</param> /// <param name="session">The client session.</param>
/// <param name="modifiedDocument">The document with the modifications you want to persist.</param> /// <param name="modifiedDocument">The document with the modifications you want to persist.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns> /// <returns>A boolean value indicating success.</returns>
public virtual bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken)) public virtual bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
@@ -51,7 +51,7 @@ namespace MongoDbGenericRepository
/// <param name="documentToModify">The document to modify.</param> /// <param name="documentToModify">The document to modify.</param>
/// <param name="update">The update definition.</param> /// <param name="update">The update definition.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns> /// <returns>A boolean value indicating success.</returns>
public virtual async Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken = default(CancellationToken)) public virtual async Task<bool> UpdateOneAsync<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
@@ -68,7 +68,7 @@ namespace MongoDbGenericRepository
/// <param name="documentToModify">The document to modify.</param> /// <param name="documentToModify">The document to modify.</param>
/// <param name="update">The update definition.</param> /// <param name="update">The update definition.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns> /// <returns>A boolean value indicating success.</returns>
public virtual bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken = default(CancellationToken)) public virtual bool UpdateOne<TDocument, TKey>(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition<TDocument> update, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
@@ -87,7 +87,7 @@ namespace MongoDbGenericRepository
/// <param name="field">The field to update.</param> /// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param> /// <param name="value">The value of the field.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns> /// <returns>A boolean value indicating success.</returns>
public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken = default(CancellationToken)) public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
@@ -106,7 +106,7 @@ namespace MongoDbGenericRepository
/// <param name="field">The field to update.</param> /// <param name="field">The field to update.</param>
/// <param name="value">The value of the field.</param> /// <param name="value">The value of the field.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns> /// <returns>A boolean value indicating success.</returns>
public virtual bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken = default(CancellationToken)) public virtual bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, TDocument documentToModify, Expression<Func<TDocument, TField>> field, TField value, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
@@ -126,7 +126,7 @@ namespace MongoDbGenericRepository
/// <param name="value">The value of the field.</param> /// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param> /// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns> /// <returns>A boolean value indicating success.</returns>
public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
@@ -146,7 +146,7 @@ namespace MongoDbGenericRepository
/// <param name="value">The value of the field.</param> /// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param> /// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns> /// <returns>A boolean value indicating success.</returns>
public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) public virtual async Task<bool> UpdateOneAsync<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
@@ -166,7 +166,7 @@ namespace MongoDbGenericRepository
/// <param name="value">The value of the field.</param> /// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param> /// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns> /// <returns>A boolean value indicating success.</returns>
public virtual bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) public virtual bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
@@ -186,7 +186,7 @@ namespace MongoDbGenericRepository
/// <param name="value">The value of the field.</param> /// <param name="value">The value of the field.</param>
/// <param name="partitionKey">The optional partition key.</param> /// <param name="partitionKey">The optional partition key.</param>
/// <param name="cancellationToken">The optional cancellation token.</param> /// <param name="cancellationToken">The optional cancellation token.</param>
/// <returns></returns> /// <returns>A boolean value indicating success.</returns>
public virtual bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) public virtual bool UpdateOne<TDocument, TKey, TField>(IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken))
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
@@ -168,6 +168,119 @@ namespace MongoDbGenericRepository
return await MongoDbUpdater.UpdateOneAsync<TDocument, Guid, TField>(filter, field, value, partitionKey); return await MongoDbUpdater.UpdateOneAsync<TDocument, Guid, TField>(filter, field, value, partitionKey);
} }
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual async Task<long> UpdateManyAsync<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<Guid>
{
return await MongoDbUpdater.UpdateManyAsync<TDocument, Guid, TField>(filter, field, value, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual async Task<long> UpdateManyAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<Guid>
{
return await MongoDbUpdater.UpdateManyAsync<TDocument, Guid, TField>(filter, field, value, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual async Task<long> UpdateManyAsync<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<Guid>
{
return await MongoDbUpdater.UpdateManyAsync<TDocument, Guid>(filter, updateDefinition, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public async Task<long> UpdateManyAsync<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<Guid>
{
return await MongoDbUpdater.UpdateManyAsync<TDocument, Guid>(filter, updateDefinition, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual long UpdateMany<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<Guid>
{
return MongoDbUpdater.UpdateMany<TDocument, Guid, TField>(filter, field, value, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual long UpdateMany<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<Guid>
{
return MongoDbUpdater.UpdateMany<TDocument, Guid, TField>(filter, field, value, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual long UpdateMany<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<Guid>
{
return MongoDbUpdater.UpdateMany<TDocument, Guid>(filter, updateDefinition, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public long UpdateMany<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<Guid>
{
return MongoDbUpdater.UpdateMany<TDocument, Guid>(filter, updateDefinition, partitionKey);
}
#endregion Update #endregion Update
#region Update TKey #region Update TKey
@@ -326,6 +439,133 @@ namespace MongoDbGenericRepository
return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey, TField>(Builders<TDocument>.Filter.Where(filter), field, value, partitionKey); return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey, TField>(Builders<TDocument>.Filter.Where(filter), field, value, partitionKey);
} }
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
public virtual async Task<long> UpdateManyAsync<TDocument, TKey, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await MongoDbUpdater.UpdateManyAsync<TDocument, TKey, TField>(filter, field, value, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual async Task<long> UpdateManyAsync<TDocument, TKey, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await MongoDbUpdater.UpdateManyAsync<TDocument, TKey, TField>(filter, field, value, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual async Task<long> UpdateManyAsync<TDocument, TKey>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await MongoDbUpdater.UpdateManyAsync<TDocument, TKey>(filter, updateDefinition, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual async Task<long> UpdateManyAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await MongoDbUpdater.UpdateManyAsync<TDocument, TKey>(filter, updateDefinition, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
public virtual long UpdateMany<TDocument, TKey, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return MongoDbUpdater.UpdateMany<TDocument, TKey, TField>(filter, field, value, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual long UpdateMany<TDocument, TKey, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return MongoDbUpdater.UpdateMany<TDocument, TKey, TField>(filter, field, value, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual long UpdateMany<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return MongoDbUpdater.UpdateMany<TDocument, TKey>(filter, updateDefinition, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual long UpdateMany<TDocument, TKey>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return MongoDbUpdater.UpdateMany<TDocument, TKey>(filter, updateDefinition, partitionKey);
}
#endregion Update #endregion Update
} }
@@ -7,10 +7,20 @@ using System.Linq.Expressions;
namespace MongoDbGenericRepository.DataAccess.Base namespace MongoDbGenericRepository.DataAccess.Base
{ {
/// <summary>
/// A base class for accessing the Database and its Collections.
/// </summary>
public class DataAccessBase public class DataAccessBase
{ {
/// <summary>
/// The MongoDbContext
/// </summary>
protected IMongoDbContext MongoDbContext; protected IMongoDbContext MongoDbContext;
/// <summary>
/// The constructor of the DataAccessBase class
/// </summary>
/// <param name="mongoDbContext"></param>
public DataAccessBase(IMongoDbContext mongoDbContext) public DataAccessBase(IMongoDbContext mongoDbContext)
{ {
MongoDbContext = mongoDbContext; MongoDbContext = mongoDbContext;
@@ -108,7 +118,6 @@ namespace MongoDbGenericRepository.DataAccess.Base
LanguageOverride = indexCreationOptions.LanguageOverride, LanguageOverride = indexCreationOptions.LanguageOverride,
ExpireAfter = indexCreationOptions.ExpireAfter, ExpireAfter = indexCreationOptions.ExpireAfter,
DefaultLanguage = indexCreationOptions.DefaultLanguage, DefaultLanguage = indexCreationOptions.DefaultLanguage,
BucketSize = indexCreationOptions.BucketSize,
Bits = indexCreationOptions.Bits, Bits = indexCreationOptions.Bits,
Background = indexCreationOptions.Background, Background = indexCreationOptions.Background,
Version = indexCreationOptions.Version Version = indexCreationOptions.Version
@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace MongoDbGenericRepository.DataAccess.Read namespace MongoDbGenericRepository.DataAccess.Read
@@ -25,12 +26,13 @@ namespace MongoDbGenericRepository.DataAccess.Read
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="id">The Id of the document you want to get.</param> /// <param name="id">The Id of the document you want to get.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
public async virtual Task<TDocument> GetByIdAsync<TDocument, TKey>(TKey id, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public async virtual Task<TDocument> GetByIdAsync<TDocument, TKey>(TKey id, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
var filter = Builders<TDocument>.Filter.Eq("Id", id); var filter = Builders<TDocument>.Filter.Eq("Id", id);
return await HandlePartitioned<TDocument, TKey>(partitionKey).Find(filter).FirstOrDefaultAsync(); return await HandlePartitioned<TDocument, TKey>(partitionKey).Find(filter).FirstOrDefaultAsync(cancellationToken);
} }
/// <summary> /// <summary>
@@ -55,11 +57,12 @@ namespace MongoDbGenericRepository.DataAccess.Read
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
public async virtual Task<TDocument> GetOneAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public async virtual Task<TDocument> GetOneAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await HandlePartitioned<TDocument, TKey>(partitionKey).Find(filter).FirstOrDefaultAsync(); return await HandlePartitioned<TDocument, TKey>(partitionKey).Find(filter).FirstOrDefaultAsync(cancellationToken);
} }
/// <summary> /// <summary>
@@ -97,11 +100,12 @@ namespace MongoDbGenericRepository.DataAccess.Read
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
public async virtual Task<bool> AnyAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public async virtual Task<bool> AnyAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
var count = await HandlePartitioned<TDocument, TKey>(partitionKey).CountDocumentsAsync(filter); var count = await HandlePartitioned<TDocument, TKey>(partitionKey).CountDocumentsAsync(filter, cancellationToken: cancellationToken);
return (count > 0); return (count > 0);
} }
@@ -127,11 +131,12 @@ namespace MongoDbGenericRepository.DataAccess.Read
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
public async virtual Task<List<TDocument>> GetAllAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public async virtual Task<List<TDocument>> GetAllAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await HandlePartitioned<TDocument, TKey>(partitionKey).Find(filter).ToListAsync(); return await HandlePartitioned<TDocument, TKey>(partitionKey).Find(filter).ToListAsync(cancellationToken);
} }
/// <summary> /// <summary>
@@ -155,11 +160,12 @@ namespace MongoDbGenericRepository.DataAccess.Read
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="partitionKey">An optional partitionKey</param> /// <param name="partitionKey">An optional partitionKey</param>
public async virtual Task<long> CountAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public async virtual Task<long> CountAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await HandlePartitioned<TDocument, TKey>(partitionKey).CountDocumentsAsync(filter); return await HandlePartitioned<TDocument, TKey>(partitionKey).CountDocumentsAsync(filter, cancellationToken: cancellationToken);
} }
/// <summary> /// <summary>
@@ -187,15 +193,16 @@ namespace MongoDbGenericRepository.DataAccess.Read
/// <typeparam name="TKey">The type of the primary key.</typeparam> /// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="maxValueSelector">A property selector to order by descending.</param> /// <param name="maxValueSelector">A property selector to order by descending.</param>
/// <param name="partitionKey">An optional partitionKey.</param> /// <param name="partitionKey">An optional partitionKey.</param
public async virtual Task<TDocument> GetByMaxAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> maxValueSelector, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public async virtual Task<TDocument> GetByMaxAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> maxValueSelector, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await GetCollection<TDocument, TKey>(partitionKey).Find(Builders<TDocument>.Filter.Where(filter)) return await GetCollection<TDocument, TKey>(partitionKey).Find(Builders<TDocument>.Filter.Where(filter))
.SortByDescending(maxValueSelector) .SortByDescending(maxValueSelector)
.Limit(1) .Limit(1)
.FirstOrDefaultAsync(); .FirstOrDefaultAsync(cancellationToken);
} }
/// <summary> /// <summary>
@@ -224,14 +231,15 @@ namespace MongoDbGenericRepository.DataAccess.Read
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="minValueSelector">A property selector to order by ascending.</param> /// <param name="minValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partitionKey.</param> /// <param name="partitionKey">An optional partitionKey.</param>
public async virtual Task<TDocument> GetByMinAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> minValueSelector, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public async virtual Task<TDocument> GetByMinAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> minValueSelector, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await GetCollection<TDocument, TKey>(partitionKey).Find(Builders<TDocument>.Filter.Where(filter)) return await GetCollection<TDocument, TKey>(partitionKey).Find(Builders<TDocument>.Filter.Where(filter))
.SortBy(minValueSelector) .SortBy(minValueSelector)
.Limit(1) .Limit(1)
.FirstOrDefaultAsync(); .FirstOrDefaultAsync(cancellationToken);
} }
/// <summary> /// <summary>
@@ -257,16 +265,18 @@ namespace MongoDbGenericRepository.DataAccess.Read
/// </summary> /// </summary>
/// <typeparam name="TDocument">The document type.</typeparam> /// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam> /// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <typeparam name="TValue">The type of the field for which you want the maximum value.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="orderByAscending">A property selector to order by ascending.</param> /// <param name="maxValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partitionKey.</param> /// <param name="partitionKey">An optional partitionKey.</param>
public async virtual Task<TValue> GetMaxValueAsync<TDocument, TKey, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> maxValueSelector, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public async virtual Task<TValue> GetMaxValueAsync<TDocument, TKey, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> maxValueSelector, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await GetMaxMongoQuery<TDocument, TKey, TValue>(filter, maxValueSelector, partitionKey) return await GetMaxMongoQuery<TDocument, TKey, TValue>(filter, maxValueSelector, partitionKey)
.Project(maxValueSelector) .Project(maxValueSelector)
.FirstOrDefaultAsync(); .FirstOrDefaultAsync(cancellationToken);
} }
/// <summary> /// <summary>
@@ -296,11 +306,12 @@ namespace MongoDbGenericRepository.DataAccess.Read
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="minValueSelector">A property selector to order by ascending.</param> /// <param name="minValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
public virtual async Task<TValue> GetMinValueAsync<TDocument, TKey, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> minValueSelector, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public virtual async Task<TValue> GetMinValueAsync<TDocument, TKey, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> minValueSelector, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await GetMinMongoQuery<TDocument, TKey, TValue>(filter, minValueSelector, partitionKey).Project(minValueSelector).FirstOrDefaultAsync(); return await GetMinMongoQuery<TDocument, TKey, TValue>(filter, minValueSelector, partitionKey).Project(minValueSelector).FirstOrDefaultAsync(cancellationToken);
} }
/// <summary> /// <summary>
@@ -332,13 +343,15 @@ namespace MongoDbGenericRepository.DataAccess.Read
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="selector">The field you want to sum.</param> /// <param name="selector">The field you want to sum.</param>
/// <param name="partitionKey">The partition key of your document, if any.</param> /// <param name="partitionKey">The partition key of your document, if any.</param>
/// <param name="cancellationToken">An optional cancellation Token.</param>
public virtual async Task<int> SumByAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, public virtual async Task<int> SumByAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, int>> selector, Expression<Func<TDocument, int>> selector,
string partitionKey = null) string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await GetQuery<TDocument, TKey>(filter, partitionKey).SumAsync(selector); return await GetQuery<TDocument, TKey>(filter, partitionKey).SumAsync(selector, cancellationToken);
} }
/// <summary> /// <summary>
@@ -366,13 +379,14 @@ namespace MongoDbGenericRepository.DataAccess.Read
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="selector">The field you want to sum.</param> /// <param name="selector">The field you want to sum.</param>
/// <param name="partitionKey">The partition key of your document, if any.</param> /// <param name="partitionKey">The partition key of your document, if any.</param>
/// <param name="cancellationToken">An optional cancellation Token.</param>
public virtual async Task<decimal> SumByAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, public virtual async Task<decimal> SumByAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, decimal>> selector, Expression<Func<TDocument, decimal>> selector,
string partitionKey = null) string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await GetQuery<TDocument, TKey>(filter, partitionKey).SumAsync(selector); return await GetQuery<TDocument, TKey>(filter, partitionKey).SumAsync(selector, cancellationToken);
} }
/// <summary> /// <summary>
@@ -451,6 +465,36 @@ namespace MongoDbGenericRepository.DataAccess.Read
.ToList(); .ToList();
} }
/// <summary>
/// Groups filtered a collection of documents given a grouping criteria,
/// and returns a dictionary of listed document groups with keys having the different values of the grouping criteria.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TGroupKey">The type of the grouping criteria.</typeparam>
/// <typeparam name="TProjection">The type of the projected group.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="selector">The grouping criteria.</param>
/// <param name="projection">The projected group result.</param>
/// <param name="partitionKey">The partition key of your document, if any.</param>
/// <param name="cancellationToken">An optional cancellation Token.</param>
public virtual async Task<List<TProjection>> GroupByAsync<TDocument, TGroupKey, TProjection, TKey>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TGroupKey>> selector,
Expression<Func<IGrouping<TGroupKey, TDocument>, TProjection>> projection,
string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
where TProjection : class, new()
{
var collection = HandlePartitioned<TDocument, TKey>(partitionKey);
return await collection.Aggregate()
.Match(Builders<TDocument>.Filter.Where(filter))
.Group(selector, projection)
.ToListAsync(cancellationToken);
}
/// <summary> /// <summary>
/// Asynchronously returns a paginated list of the documents matching the filter condition. /// Asynchronously returns a paginated list of the documents matching the filter condition.
/// </summary> /// </summary>
@@ -462,13 +506,15 @@ namespace MongoDbGenericRepository.DataAccess.Read
/// <param name="skipNumber">The number of documents you want to skip. Default value is 0.</param> /// <param name="skipNumber">The number of documents you want to skip. Default value is 0.</param>
/// <param name="takeNumber">The number of documents you want to take. Default value is 50.</param> /// <param name="takeNumber">The number of documents you want to take. Default value is 50.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
/// <param name="cancellationToken">An optional cancellation Token.</param>
public virtual async Task<List<TDocument>> GetSortedPaginatedAsync<TDocument, TKey>( public virtual async Task<List<TDocument>> GetSortedPaginatedAsync<TDocument, TKey>(
Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, object>> sortSelector, Expression<Func<TDocument, object>> sortSelector,
bool ascending = true, bool ascending = true,
int skipNumber = 0, int skipNumber = 0,
int takeNumber = 50, int takeNumber = 50,
string partitionKey = null) string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
@@ -481,7 +527,7 @@ namespace MongoDbGenericRepository.DataAccess.Read
.Sort(sorting) .Sort(sorting)
.Skip(skipNumber) .Skip(skipNumber)
.Limit(takeNumber) .Limit(takeNumber)
.ToListAsync(); .ToListAsync(cancellationToken);
} }
/// <summary> /// <summary>
@@ -494,12 +540,14 @@ namespace MongoDbGenericRepository.DataAccess.Read
/// <param name="skipNumber">The number of documents you want to skip. Default value is 0.</param> /// <param name="skipNumber">The number of documents you want to skip. Default value is 0.</param>
/// <param name="takeNumber">The number of documents you want to take. Default value is 50.</param> /// <param name="takeNumber">The number of documents you want to take. Default value is 50.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
/// <param name="cancellationToken">An optional cancellation Token.</param>
public virtual async Task<List<TDocument>> GetSortedPaginatedAsync<TDocument, TKey>( public virtual async Task<List<TDocument>> GetSortedPaginatedAsync<TDocument, TKey>(
Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, bool>> filter,
SortDefinition<TDocument> sortDefinition, SortDefinition<TDocument> sortDefinition,
int skipNumber = 0, int skipNumber = 0,
int takeNumber = 50, int takeNumber = 50,
string partitionKey = null) string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
@@ -508,7 +556,7 @@ namespace MongoDbGenericRepository.DataAccess.Read
.Sort(sortDefinition) .Sort(sortDefinition)
.Skip(skipNumber) .Skip(skipNumber)
.Limit(takeNumber) .Limit(takeNumber)
.ToListAsync(); .ToListAsync(cancellationToken);
} }
} }
} }
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace MongoDbGenericRepository.DataAccess.Read namespace MongoDbGenericRepository.DataAccess.Read
@@ -20,14 +21,19 @@ namespace MongoDbGenericRepository.DataAccess.Read
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="projection">The projection expression.</param> /// <param name="projection">The projection expression.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
public virtual async Task<TProjection> ProjectOneAsync<TDocument, TProjection, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TProjection>> projection, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public virtual async Task<TProjection> ProjectOneAsync<TDocument, TProjection, TKey>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TProjection>> projection,
string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
where TProjection : class where TProjection : class
{ {
return await HandlePartitioned<TDocument, TKey>(partitionKey).Find(filter) return await HandlePartitioned<TDocument, TKey>(partitionKey).Find(filter)
.Project(projection) .Project(projection)
.FirstOrDefaultAsync(); .FirstOrDefaultAsync(cancellationToken);
} }
/// <summary> /// <summary>
@@ -58,14 +64,19 @@ namespace MongoDbGenericRepository.DataAccess.Read
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="projection">The projection expression.</param> /// <param name="projection">The projection expression.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
public virtual async Task<List<TProjection>> ProjectManyAsync<TDocument, TProjection, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TProjection>> projection, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public virtual async Task<List<TProjection>> ProjectManyAsync<TDocument, TProjection, TKey>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TProjection>> projection,
string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
where TProjection : class where TProjection : class
{ {
return await HandlePartitioned<TDocument, TKey>(partitionKey).Find(filter) return await HandlePartitioned<TDocument, TKey>(partitionKey).Find(filter)
.Project(projection) .Project(projection)
.ToListAsync(); .ToListAsync(cancellationToken);
} }
/// <summary> /// <summary>
@@ -62,7 +62,7 @@ namespace MongoDbGenericRepository.DataAccess.Update
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
var filter = Builders<TDocument>.Filter.Eq("Id", documentToModify.Id); var filter = Builders<TDocument>.Filter.Eq("Id", documentToModify.Id);
var updateRes = await HandlePartitioned<TDocument, TKey>(documentToModify).UpdateOneAsync(session, filter, update, new UpdateOptions { IsUpsert = true }, cancellationToken).ConfigureAwait(false); var updateRes = await HandlePartitioned<TDocument, TKey>(documentToModify).UpdateOneAsync(session, filter, update, null, cancellationToken).ConfigureAwait(false);
return updateRes.ModifiedCount == 1; return updateRes.ModifiedCount == 1;
} }
@@ -81,7 +81,7 @@ namespace MongoDbGenericRepository.DataAccess.Update
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
var filter = Builders<TDocument>.Filter.Eq("Id", documentToModify.Id); var filter = Builders<TDocument>.Filter.Eq("Id", documentToModify.Id);
var updateRes = HandlePartitioned<TDocument, TKey>(documentToModify).UpdateOne(session, filter, update, new UpdateOptions { IsUpsert = true }, cancellationToken); var updateRes = HandlePartitioned<TDocument, TKey>(documentToModify).UpdateOne(session, filter, update, null, cancellationToken);
return updateRes.ModifiedCount == 1; return updateRes.ModifiedCount == 1;
} }
@@ -56,7 +56,7 @@ namespace MongoDbGenericRepository.DataAccess.Update
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
var filter = Builders<TDocument>.Filter.Eq("Id", documentToModify.Id); var filter = Builders<TDocument>.Filter.Eq("Id", documentToModify.Id);
var updateRes = await HandlePartitioned<TDocument, TKey>(documentToModify).UpdateOneAsync(filter, update, new UpdateOptions { IsUpsert = true }); var updateRes = await HandlePartitioned<TDocument, TKey>(documentToModify).UpdateOneAsync(filter, update);
return updateRes.ModifiedCount == 1; return updateRes.ModifiedCount == 1;
} }
@@ -72,7 +72,7 @@ namespace MongoDbGenericRepository.DataAccess.Update
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
var filter = Builders<TDocument>.Filter.Eq("Id", documentToModify.Id); var filter = Builders<TDocument>.Filter.Eq("Id", documentToModify.Id);
var updateRes = HandlePartitioned<TDocument, TKey>(documentToModify).UpdateOne(filter, update, new UpdateOptions { IsUpsert = true }); var updateRes = HandlePartitioned<TDocument, TKey>(documentToModify).UpdateOne(filter, update);
return updateRes.ModifiedCount == 1; return updateRes.ModifiedCount == 1;
} }
@@ -183,5 +183,129 @@ namespace MongoDbGenericRepository.DataAccess.Update
{ {
return UpdateOne<TDocument, TKey, TField>(Builders<TDocument>.Filter.Where(filter), field, value, partitionKey); return UpdateOne<TDocument, TKey, TField>(Builders<TDocument>.Filter.Where(filter), field, value, partitionKey);
} }
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
public virtual async Task<long> UpdateManyAsync<TDocument, TKey, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await UpdateManyAsync<TDocument, TKey, TField>(Builders<TDocument>.Filter.Where(filter), field, value, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual async Task<long> UpdateManyAsync<TDocument, TKey, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
var collection = string.IsNullOrEmpty(partitionKey) ? GetCollection<TDocument, TKey>() : GetCollection<TDocument, TKey>(partitionKey);
var updateRes = await collection.UpdateManyAsync(filter, Builders<TDocument>.Update.Set(field, value));
return updateRes.ModifiedCount;
}
/// <summary>
/// For the entities selected by the filter, apply the update definition.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual async Task<long> UpdateManyAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> update, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await UpdateManyAsync<TDocument, TKey>(Builders<TDocument>.Filter.Where(filter), update, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, apply the update definition.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual async Task<long> UpdateManyAsync<TDocument, TKey>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
var collection = string.IsNullOrEmpty(partitionKey) ? GetCollection<TDocument, TKey>() : GetCollection<TDocument, TKey>(partitionKey);
var updateRes = await collection.UpdateManyAsync(filter, updateDefinition);
return updateRes.ModifiedCount;
}
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
public virtual long UpdateMany<TDocument, TKey, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return UpdateMany<TDocument, TKey, TField>(Builders<TDocument>.Filter.Where(filter), field, value, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual long UpdateMany<TDocument, TKey, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
var collection = string.IsNullOrEmpty(partitionKey) ? GetCollection<TDocument, TKey>() : GetCollection<TDocument, TKey>(partitionKey);
var updateRes = collection.UpdateMany(filter, Builders<TDocument>.Update.Set(field, value));
return updateRes.ModifiedCount;
}
/// <summary>
/// For the entities selected by the filter, apply the update definition.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="UpdateDefinition">The update definition.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual long UpdateMany<TDocument, TKey>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> UpdateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
var collection = string.IsNullOrEmpty(partitionKey) ? GetCollection<TDocument, TKey>() : GetCollection<TDocument, TKey>(partitionKey);
var updateRes = collection.UpdateMany(filter, UpdateDefinition);
return updateRes.ModifiedCount;
}
} }
} }
@@ -110,6 +110,94 @@ namespace MongoDbGenericRepository
/// <param name="partitionKey">The partition key for the document.</param> /// <param name="partitionKey">The partition key for the document.</param>
Task<bool> UpdateOneAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null) Task<bool> UpdateOneAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>; where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
Task<long> UpdateManyAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
Task<long> UpdateManyAsync<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
Task<long> UpdateManyAsync<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
Task<long> UpdateManyAsync<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
long UpdateMany<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
long UpdateMany<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
long UpdateMany<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>;
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
long UpdateMany<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>;
} }
public abstract partial class BaseMongoRepository<TKey> : IBaseMongoRepository_Update<TKey> public abstract partial class BaseMongoRepository<TKey> : IBaseMongoRepository_Update<TKey>
@@ -266,5 +354,116 @@ namespace MongoDbGenericRepository
{ {
return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey, TField>(filter, field, value, partitionKey); return await MongoDbUpdater.UpdateOneAsync<TDocument, TKey, TField>(filter, field, value, partitionKey);
} }
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
public virtual async Task<long> UpdateManyAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
{
return await MongoDbUpdater.UpdateManyAsync<TDocument, TKey, TField>(filter, field, value, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual async Task<long> UpdateManyAsync<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
{
return await MongoDbUpdater.UpdateManyAsync<TDocument, TKey, TField>(filter, field, value, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual async Task<long> UpdateManyAsync<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>
{
return await MongoDbUpdater.UpdateManyAsync<TDocument, TKey>(filter, updateDefinition, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual async Task<long> UpdateManyAsync<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>
{
return await MongoDbUpdater.UpdateManyAsync<TDocument, TKey>(filter, updateDefinition, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The partition key for the document.</param>
public virtual long UpdateMany<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
{
return MongoDbUpdater.UpdateMany<TDocument, TKey, TField>(filter, field, value, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, updates the property field with the given value.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TField">The type of the field.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="field">The field selector.</param>
/// <param name="value">The new value of the property field.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual long UpdateMany<TDocument, TField>(FilterDefinition<TDocument> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument<TKey>
{
return MongoDbUpdater.UpdateMany<TDocument, TKey, TField>(filter, field, value, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual long UpdateMany<TDocument>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null)
where TDocument : IDocument<TKey>
{
return MongoDbUpdater.UpdateMany<TDocument, TKey>(filter, updateDefinition, partitionKey);
}
/// <summary>
/// For the entities selected by the filter, applies the update you have defined in MongoDb.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="filter">The document filter.</param>
/// <param name="updateDefinition">The update definition to apply.</param>
/// <param name="partitionKey">The value of the partition key.</param>
public virtual long UpdateMany<TDocument>(Expression<Func<TDocument, bool>> filter, UpdateDefinition<TDocument> updateDefinition, string partitionKey = null) where TDocument : IDocument<TKey>
{
return MongoDbUpdater.UpdateMany<TDocument, TKey>(filter, updateDefinition, partitionKey);
}
} }
} }
+1 -2
View File
@@ -1,5 +1,4 @@
using MongoDB.Bson.Serialization.Attributes; using System;
using System;
namespace MongoDbGenericRepository.Models namespace MongoDbGenericRepository.Models
{ {
@@ -52,10 +52,6 @@ namespace MongoDbGenericRepository.Models
/// </summary> /// </summary>
public string DefaultLanguage { get; set; } public string DefaultLanguage { get; set; }
/// <summary> /// <summary>
/// Gets or sets the size of a geohash bucket.
/// </summary>
public double? BucketSize { get; set; }
/// <summary>
/// Gets or sets the precision, in bits, used with geohash indexes. /// Gets or sets the precision, in bits, used with geohash indexes.
/// </summary> /// </summary>
public int? Bits { get; set; } public int? Bits { get; set; }
@@ -2,26 +2,30 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net452;netstandard2.0;netstandard1.5;</TargetFrameworks> <TargetFrameworks>net452;netstandard2.0;netstandard1.5;</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageId>MongoDbGenericRepository</PackageId> <PackageId>MongoDbGenericRepository</PackageId>
<PackageVersion>1.2.0</PackageVersion> <PackageVersion>1.4.6</PackageVersion>
<Authors>Alexandre Spieser</Authors> <Authors>Alexandre Spieser</Authors>
<PackageTitle>MongoDb Generic Repository</PackageTitle>
<Description>A generic repository implementation using the MongoDB C# Sharp 2.0 driver.</Description> <Description>A generic repository implementation using the MongoDB C# Sharp 2.0 driver.</Description>
<PackageLicenseUrl>http://www.opensource.org/licenses/mit-license.php</PackageLicenseUrl>
<PackageProjectUrl>http://www.opensource.org/licenses/mit-license.php</PackageProjectUrl>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance> <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>.NET Core supported.</PackageReleaseNotes> <PackageReleaseNotes>Release notes are at https://github.com/alexandre-spieser/mongodb-generic-repository/releases </PackageReleaseNotes>
<Copyright>Copyright 2017 (c) Alexandre Spieser. All rights reserved.</Copyright> <Copyright>Copyright 2020 (c) Alexandre Spieser. All rights reserved.</Copyright>
<PackageTags>MongoDb Repository NoSql Generic</PackageTags> <PackageTags>MongoDb Repository Generic NoSql</PackageTags>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.4.6</Version>
<RepositoryUrl>https://github.com/alexandre-spieser/mongodb-generic-repository</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net45|AnyCPU'"> <PropertyGroup>
<DocumentationFile>bin\Release\net45\MongoDbGenericRepository.xml</DocumentationFile> <DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net452|AnyCPU'">
<DocumentationFile></DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.9.3" /> <PackageReference Include="MongoDB.Driver" Version="2.12.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>
@@ -2,7 +2,7 @@
<package > <package >
<metadata> <metadata>
<id>MongoDbGenericRepository</id> <id>MongoDbGenericRepository</id>
<version>1.4.3</version> <version>1.4.5</version>
<title>MongoDb Generic Repository</title> <title>MongoDb Generic Repository</title>
<authors>Alexandre Spieser</authors> <authors>Alexandre Spieser</authors>
<owners>Alexandre Spieser</owners> <owners>Alexandre Spieser</owners>
@@ -11,7 +11,7 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A generic repository implementation using the MongoDB C# Sharp 2.0 driver.</description> <description>A generic repository implementation using the MongoDB C# Sharp 2.0 driver.</description>
<releaseNotes>Release notes are at https://github.com/alexandre-spieser/mongodb-generic-repository/releases</releaseNotes> <releaseNotes>Release notes are at https://github.com/alexandre-spieser/mongodb-generic-repository/releases</releaseNotes>
<copyright>Copyright 2019 (c) Alexandre Spieser. All rights reserved.</copyright> <copyright>Copyright 2020 (c) Alexandre Spieser. All rights reserved.</copyright>
<tags>MongoDb Repository Generic NoSql</tags> <tags>MongoDb Repository Generic NoSql</tags>
<dependencies> <dependencies>
<group targetFramework=".NETFramework4.5.2"> <group targetFramework=".NETFramework4.5.2">
@@ -155,6 +155,94 @@
<param name="value">The new value of the property field.</param> <param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param> <param name="partitionKey">The value of the partition key.</param>
</member> </member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update.UpdateManyAsync``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update.UpdateManyAsync``3(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update.UpdateManyAsync``2(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update.UpdateManyAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update.UpdateMany``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update.UpdateMany``3(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update.UpdateMany``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update.UpdateMany``2(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.DataAccess.Update.IBaseMongoRepository_Update_ClientSession.UpdateOne``3(MongoDB.Driver.IClientSessionHandle,System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String,System.Threading.CancellationToken)"> <member name="M:MongoDbGenericRepository.DataAccess.Update.IBaseMongoRepository_Update_ClientSession.UpdateOne``3(MongoDB.Driver.IClientSessionHandle,System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String,System.Threading.CancellationToken)">
<summary> <summary>
Updates a document. Updates a document.
@@ -527,6 +615,87 @@
<param name="value">The new value of the property field.</param> <param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param> <param name="partitionKey">The partition key for the document.</param>
</member> </member>
<member name="M:MongoDbGenericRepository.DataAccess.Update.MongoDbUpdater.UpdateManyAsync``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.DataAccess.Update.MongoDbUpdater.UpdateManyAsync``3(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.DataAccess.Update.MongoDbUpdater.UpdateManyAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, apply the update definition.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.DataAccess.Update.MongoDbUpdater.UpdateManyAsync``2(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, apply the update definition.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.DataAccess.Update.MongoDbUpdater.UpdateMany``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.DataAccess.Update.MongoDbUpdater.UpdateMany``3(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.DataAccess.Update.MongoDbUpdater.UpdateMany``2(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, apply the update definition.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="UpdateDefinition">The update definition.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.DataAccess.Base.DataAccessBase.HandlePartitioned``2(``0)"> <member name="M:MongoDbGenericRepository.DataAccess.Base.DataAccessBase.HandlePartitioned``2(``0)">
<summary> <summary>
Gets a collections for a potentially partitioned document type. Gets a collections for a potentially partitioned document type.
@@ -2506,6 +2675,87 @@
<param name="value">The new value of the property field.</param> <param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param> <param name="partitionKey">The partition key for the document.</param>
</member> </member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateManyAsync``2(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateManyAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateManyAsync``1(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateManyAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateMany``2(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateMany``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateMany``1(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateMany``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateOneAsync``2(``0)"> <member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateOneAsync``2(``0)">
<summary> <summary>
Asynchronously Updates a document. Asynchronously Updates a document.
@@ -2610,6 +2860,94 @@
<param name="value">The new value of the property field.</param> <param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param> <param name="partitionKey">The partition key for the document.</param>
</member> </member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateManyAsync``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateManyAsync``3(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateManyAsync``2(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateManyAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateMany``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateMany``3(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateMany``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateMany``2(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Delete.DeleteOne``2(``0)"> <member name="M:MongoDbGenericRepository.IBaseMongoRepository_Delete.DeleteOne``2(``0)">
<summary> <summary>
Deletes a document. Deletes a document.
@@ -3142,6 +3480,86 @@
<param name="value">The new value of the property field.</param> <param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param> <param name="partitionKey">The partition key for the document.</param>
</member> </member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository`1.UpdateManyAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository`1.UpdateManyAsync``2(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository`1.UpdateManyAsync``1(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository`1.UpdateManyAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository`1.UpdateMany``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository`1.UpdateMany``2(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository`1.UpdateMany``1(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository`1.UpdateMany``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="T:MongoDbGenericRepository.IBaseMongoRepository_Delete`1"> <member name="T:MongoDbGenericRepository.IBaseMongoRepository_Delete`1">
<summary> <summary>
The interface exposing deletion functionality for Key typed repositories. The interface exposing deletion functionality for Key typed repositories.
@@ -3733,6 +4151,86 @@
<param name="value">The new value of the property field.</param> <param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param> <param name="partitionKey">The partition key for the document.</param>
</member> </member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update`1.UpdateManyAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update`1.UpdateManyAsync``2(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update`1.UpdateManyAsync``1(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update`1.UpdateManyAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update`1.UpdateMany``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update`1.UpdateMany``2(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update`1.UpdateMany``1(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update`1.UpdateMany``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="T:MongoDbGenericRepository.Models.Document"> <member name="T:MongoDbGenericRepository.Models.Document">
<summary> <summary>
This class represents a basic document that can be stored in MongoDb. This class represents a basic document that can be stored in MongoDb.
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace MongoDbGenericRepository namespace MongoDbGenericRepository
@@ -49,11 +50,12 @@ namespace MongoDbGenericRepository
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="id">The Id of the document you want to get.</param> /// <param name="id">The Id of the document you want to get.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
public async virtual Task<TDocument> GetByIdAsync<TDocument, TKey>(TKey id, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public async virtual Task<TDocument> GetByIdAsync<TDocument, TKey>(TKey id, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await MongoDbReader.GetByIdAsync<TDocument, TKey>(id, partitionKey); return await MongoDbReader.GetByIdAsync<TDocument, TKey>(id, partitionKey, cancellationToken);
} }
/// <summary> /// <summary>
@@ -77,11 +79,12 @@ namespace MongoDbGenericRepository
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
public async virtual Task<TDocument> GetOneAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public async virtual Task<TDocument> GetOneAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await MongoDbReader.GetOneAsync<TDocument, TKey>(filter, partitionKey); return await MongoDbReader.GetOneAsync<TDocument, TKey>(filter, partitionKey, cancellationToken);
} }
/// <summary> /// <summary>
@@ -119,11 +122,12 @@ namespace MongoDbGenericRepository
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
public async virtual Task<bool> AnyAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public async virtual Task<bool> AnyAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await MongoDbReader.AnyAsync<TDocument, TKey>(filter, partitionKey); return await MongoDbReader.AnyAsync<TDocument, TKey>(filter, partitionKey, cancellationToken);
} }
/// <summary> /// <summary>
@@ -147,11 +151,12 @@ namespace MongoDbGenericRepository
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
public async virtual Task<List<TDocument>> GetAllAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public async virtual Task<List<TDocument>> GetAllAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await MongoDbReader.GetAllAsync<TDocument, TKey>(filter, partitionKey); return await MongoDbReader.GetAllAsync<TDocument, TKey>(filter, partitionKey, cancellationToken);
} }
/// <summary> /// <summary>
@@ -175,11 +180,12 @@ namespace MongoDbGenericRepository
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam> /// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="partitionKey">An optional partitionKey</param> /// <param name="partitionKey">An optional partitionKey</param>
public async virtual Task<long> CountAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public async virtual Task<long> CountAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await MongoDbReader.CountAsync<TDocument, TKey>(filter, partitionKey); return await MongoDbReader.CountAsync<TDocument, TKey>(filter, partitionKey, cancellationToken);
} }
/// <summary> /// <summary>
@@ -204,11 +210,15 @@ namespace MongoDbGenericRepository
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="maxValueSelector">A property selector to order by descending.</param> /// <param name="maxValueSelector">A property selector to order by descending.</param>
/// <param name="partitionKey">An optional partitionKey.</param> /// <param name="partitionKey">An optional partitionKey.</param>
public async virtual Task<TDocument> GetByMaxAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> maxValueSelector, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public async virtual Task<TDocument> GetByMaxAsync<TDocument, TKey>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, object>> maxValueSelector,
string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await MongoDbReader.GetByMaxAsync<TDocument, TKey>(filter, maxValueSelector, partitionKey); return await MongoDbReader.GetByMaxAsync<TDocument, TKey>(filter, maxValueSelector, partitionKey, cancellationToken);
} }
/// <summary> /// <summary>
@@ -232,13 +242,17 @@ namespace MongoDbGenericRepository
/// <typeparam name="TDocument">The document type.</typeparam> /// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam> /// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="minValueSelector">A property selector to order by ascending.</param> /// <param name="minValueSelector">A property selector for the minimum value you are looking for.</param>
/// <param name="partitionKey">An optional partitionKey.</param> /// <param name="partitionKey">An optional partitionKey.</param>
public async virtual Task<TDocument> GetByMinAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> minValueSelector, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public async virtual Task<TDocument> GetByMinAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, object>> minValueSelector,
string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await MongoDbReader.GetByMinAsync<TDocument, TKey>(filter, minValueSelector, partitionKey); return await MongoDbReader.GetByMinAsync<TDocument, TKey>(filter, minValueSelector, partitionKey, cancellationToken);
} }
/// <summary> /// <summary>
@@ -247,7 +261,7 @@ namespace MongoDbGenericRepository
/// <typeparam name="TDocument">The document type.</typeparam> /// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam> /// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="minValueSelector">A property selector to order by ascending.</param> /// <param name="minValueSelector">A property selector for the minimum value you are looking for.</param>
/// <param name="partitionKey">An optional partitionKey.</param> /// <param name="partitionKey">An optional partitionKey.</param>
public virtual TDocument GetByMin<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> minValueSelector, string partitionKey = null) public virtual TDocument GetByMin<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> minValueSelector, string partitionKey = null)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
@@ -263,13 +277,18 @@ namespace MongoDbGenericRepository
/// <typeparam name="TKey">The type of the primary key.</typeparam> /// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <typeparam name="TValue">The type of the value used to order the query.</typeparam> /// <typeparam name="TValue">The type of the value used to order the query.</typeparam>
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="maxValueSelector">A property selector to select the max value.</param> /// <param name="maxValueSelector">A property selector for the maximum value you are looking for.</param>
/// <param name="partitionKey">An optional partitionKey.</param> /// <param name="partitionKey">An optional partitionKey.</param>
public async virtual Task<TValue> GetMaxValueAsync<TDocument, TKey, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> maxValueSelector, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public async virtual Task<TValue> GetMaxValueAsync<TDocument, TKey, TValue>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TValue>> maxValueSelector,
string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await MongoDbReader.GetMaxValueAsync<TDocument, TKey, TValue>(filter, maxValueSelector, partitionKey); return await MongoDbReader.GetMaxValueAsync<TDocument, TKey, TValue>(filter, maxValueSelector, partitionKey, cancellationToken);
} }
/// <summary> /// <summary>
@@ -297,11 +316,16 @@ namespace MongoDbGenericRepository
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="minValueSelector">A property selector to order by ascending.</param> /// <param name="minValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
public virtual async Task<TValue> GetMinValueAsync<TDocument, TKey, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> minValueSelector, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public virtual async Task<TValue> GetMinValueAsync<TDocument, TKey, TValue>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TValue>> minValueSelector,
string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await MongoDbReader.GetMinValueAsync<TDocument, TKey, TValue>(filter, minValueSelector, partitionKey); return await MongoDbReader.GetMinValueAsync<TDocument, TKey, TValue>(filter, minValueSelector, partitionKey, cancellationToken);
} }
/// <summary> /// <summary>
@@ -332,13 +356,15 @@ namespace MongoDbGenericRepository
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="selector">The field you want to sum.</param> /// <param name="selector">The field you want to sum.</param>
/// <param name="partitionKey">The partition key of your document, if any.</param> /// <param name="partitionKey">The partition key of your document, if any.</param>
/// <param name="cancellationToken">An optional cancellation Token.</param>
public virtual async Task<int> SumByAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, public virtual async Task<int> SumByAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, int>> selector, Expression<Func<TDocument, int>> selector,
string partitionKey = null) string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
return await MongoDbReader.SumByAsync<TDocument, TKey>(filter, selector, partitionKey); return await MongoDbReader.SumByAsync<TDocument, TKey>(filter, selector, partitionKey, cancellationToken);
} }
/// <summary> /// <summary>
@@ -405,12 +431,17 @@ namespace MongoDbGenericRepository
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="projection">The projection expression.</param> /// <param name="projection">The projection expression.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
public virtual async Task<TProjection> ProjectOneAsync<TDocument, TProjection, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TProjection>> projection, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public virtual async Task<TProjection> ProjectOneAsync<TDocument, TProjection, TKey>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TProjection>> projection,
string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
where TProjection : class where TProjection : class
{ {
return await MongoDbReader.ProjectOneAsync<TDocument, TProjection, TKey>(filter, projection, partitionKey); return await MongoDbReader.ProjectOneAsync<TDocument, TProjection, TKey>(filter, projection, partitionKey, cancellationToken);
} }
/// <summary> /// <summary>
@@ -439,12 +470,16 @@ namespace MongoDbGenericRepository
/// <param name="filter">A LINQ expression filter.</param> /// <param name="filter">A LINQ expression filter.</param>
/// <param name="projection">The projection expression.</param> /// <param name="projection">The projection expression.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
public virtual async Task<List<TProjection>> ProjectManyAsync<TDocument, TProjection, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TProjection>> projection, string partitionKey = null) /// <param name="cancellationToken">An optional cancellation Token.</param>
public virtual async Task<List<TProjection>> ProjectManyAsync<TDocument, TProjection, TKey>(
Expression<Func<TDocument, bool>> filter,
Expression<Func<TDocument, TProjection>> projection,
string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
where TProjection : class where TProjection : class
{ {
return await MongoDbReader.ProjectManyAsync<TDocument, TProjection, TKey>(filter, projection, partitionKey); return await MongoDbReader.ProjectManyAsync<TDocument, TProjection, TKey>(filter, projection, partitionKey, cancellationToken);
} }
/// <summary> /// <summary>
@@ -562,12 +597,14 @@ namespace MongoDbGenericRepository
/// <param name="skipNumber">The number of documents you want to skip. Default value is 0.</param> /// <param name="skipNumber">The number of documents you want to skip. Default value is 0.</param>
/// <param name="takeNumber">The number of documents you want to take. Default value is 50.</param> /// <param name="takeNumber">The number of documents you want to take. Default value is 50.</param>
/// <param name="partitionKey">An optional partition key.</param> /// <param name="partitionKey">An optional partition key.</param>
/// <param name="cancellationToken">An optional cancellation Token.</param>
public virtual async Task<List<TDocument>> GetSortedPaginatedAsync<TDocument, TKey>( public virtual async Task<List<TDocument>> GetSortedPaginatedAsync<TDocument, TKey>(
Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, bool>> filter,
SortDefinition<TDocument> sortDefinition, SortDefinition<TDocument> sortDefinition,
int skipNumber = 0, int skipNumber = 0,
int takeNumber = 50, int takeNumber = 50,
string partitionKey = null) string partitionKey = null,
CancellationToken cancellationToken = default)
where TDocument : IDocument<TKey> where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey> where TKey : IEquatable<TKey>
{ {
@@ -576,7 +613,7 @@ namespace MongoDbGenericRepository
.Sort(sortDefinition) .Sort(sortDefinition)
.Skip(skipNumber) .Skip(skipNumber)
.Limit(takeNumber) .Limit(takeNumber)
.ToListAsync(); .ToListAsync(cancellationToken);
} }
#endregion Pagination #endregion Pagination
@@ -155,6 +155,94 @@
<param name="value">The new value of the property field.</param> <param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param> <param name="partitionKey">The value of the partition key.</param>
</member> </member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update.UpdateManyAsync``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update.UpdateManyAsync``3(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update.UpdateManyAsync``2(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update.UpdateManyAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update.UpdateMany``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update.UpdateMany``3(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update.UpdateMany``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update.UpdateMany``2(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.DataAccess.Update.IBaseMongoRepository_Update_ClientSession.UpdateOne``3(MongoDB.Driver.IClientSessionHandle,System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String,System.Threading.CancellationToken)"> <member name="M:MongoDbGenericRepository.DataAccess.Update.IBaseMongoRepository_Update_ClientSession.UpdateOne``3(MongoDB.Driver.IClientSessionHandle,System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String,System.Threading.CancellationToken)">
<summary> <summary>
Updates a document. Updates a document.
@@ -527,6 +615,87 @@
<param name="value">The new value of the property field.</param> <param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param> <param name="partitionKey">The partition key for the document.</param>
</member> </member>
<member name="M:MongoDbGenericRepository.DataAccess.Update.MongoDbUpdater.UpdateManyAsync``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.DataAccess.Update.MongoDbUpdater.UpdateManyAsync``3(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.DataAccess.Update.MongoDbUpdater.UpdateManyAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, apply the update definition.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.DataAccess.Update.MongoDbUpdater.UpdateManyAsync``2(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, apply the update definition.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.DataAccess.Update.MongoDbUpdater.UpdateMany``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.DataAccess.Update.MongoDbUpdater.UpdateMany``3(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.DataAccess.Update.MongoDbUpdater.UpdateMany``2(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, apply the update definition.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="UpdateDefinition">The update definition.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.DataAccess.Base.DataAccessBase.HandlePartitioned``2(``0)"> <member name="M:MongoDbGenericRepository.DataAccess.Base.DataAccessBase.HandlePartitioned``2(``0)">
<summary> <summary>
Gets a collections for a potentially partitioned document type. Gets a collections for a potentially partitioned document type.
@@ -2506,6 +2675,87 @@
<param name="value">The new value of the property field.</param> <param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param> <param name="partitionKey">The partition key for the document.</param>
</member> </member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateManyAsync``2(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateManyAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateManyAsync``1(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateManyAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateMany``2(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateMany``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateMany``1(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateMany``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateOneAsync``2(``0)"> <member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateOneAsync``2(``0)">
<summary> <summary>
Asynchronously Updates a document. Asynchronously Updates a document.
@@ -2610,6 +2860,94 @@
<param name="value">The new value of the property field.</param> <param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param> <param name="partitionKey">The partition key for the document.</param>
</member> </member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateManyAsync``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateManyAsync``3(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateManyAsync``2(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateManyAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateMany``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateMany``3(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateMany``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.UpdateMany``2(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Delete.DeleteOne``2(``0)"> <member name="M:MongoDbGenericRepository.IBaseMongoRepository_Delete.DeleteOne``2(``0)">
<summary> <summary>
Deletes a document. Deletes a document.
@@ -3142,6 +3480,86 @@
<param name="value">The new value of the property field.</param> <param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param> <param name="partitionKey">The partition key for the document.</param>
</member> </member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository`1.UpdateManyAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository`1.UpdateManyAsync``2(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository`1.UpdateManyAsync``1(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository`1.UpdateManyAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository`1.UpdateMany``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository`1.UpdateMany``2(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository`1.UpdateMany``1(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository`1.UpdateMany``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="T:MongoDbGenericRepository.IBaseMongoRepository_Delete`1"> <member name="T:MongoDbGenericRepository.IBaseMongoRepository_Delete`1">
<summary> <summary>
The interface exposing deletion functionality for Key typed repositories. The interface exposing deletion functionality for Key typed repositories.
@@ -3733,6 +4151,86 @@
<param name="value">The new value of the property field.</param> <param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param> <param name="partitionKey">The partition key for the document.</param>
</member> </member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update`1.UpdateManyAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update`1.UpdateManyAsync``2(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update`1.UpdateManyAsync``1(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update`1.UpdateManyAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update`1.UpdateMany``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The partition key for the document.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update`1.UpdateMany``2(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
For the entities selected by the filter, updates the property field with the given value.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TField">The type of the field.</typeparam>
<param name="filter">The document filter.</param>
<param name="field">The field selector.</param>
<param name="value">The new value of the property field.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update`1.UpdateMany``1(MongoDB.Driver.FilterDefinition{``0},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IBaseMongoRepository_Update`1.UpdateMany``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},MongoDB.Driver.UpdateDefinition{``0},System.String)">
<summary>
For the entities selected by the filter, applies the update you have defined in MongoDb.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="filter">The document filter.</param>
<param name="updateDefinition">The update definition to apply.</param>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="T:MongoDbGenericRepository.Models.Document"> <member name="T:MongoDbGenericRepository.Models.Document">
<summary> <summary>
This class represents a basic document that can be stored in MongoDb. This class represents a basic document that can be stored in MongoDb.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+13
View File
@@ -1,4 +1,5 @@
# MongoDbGenericRepository # MongoDbGenericRepository
An example of generic repository implementation using the MongoDB C# Sharp 2.0 driver (async) An example of generic repository implementation using the MongoDB C# Sharp 2.0 driver (async)
Now available as a nuget package: Now available as a nuget package:
@@ -8,6 +9,18 @@ Covered by 400+ integration tests and counting.
The MongoDbGenericRepository is also used in [AspNetCore.Identity.MongoDbCore](https://github.com/alexandre-spieser/AspNetCore.Identity.MongoDbCore). The MongoDbGenericRepository is also used in [AspNetCore.Identity.MongoDbCore](https://github.com/alexandre-spieser/AspNetCore.Identity.MongoDbCore).
# Support This Project
If you have found this project helpful, either as a library that you use or as a learning tool, please consider buying Alex a coffee: <a href="https://www.buymeacoffee.com/zeitquest" target="_blank"><img height="40px" src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" style="max-height: 51px;width: 150px !important;" ></a>
# Worth Knowing
This package sets the `MongoDefaults.GuidRepresentation` to `MongoDB.Bson.GuidRepresentation.Standard` by default, instead of the default driver setting of `MongoDB.Bson.GuidRepresentation.CSharpLegacy`. This can cause issues if you have been using the driver on an existing application previously or if you are using CosmosDB.
You can override this behaviour to enforce legacy behaviour in your app Startup routine like so :
`MongoDbContext.SetGuidRepresentation(MongoDB.Bson.GuidRepresentation.CSharpLegacy)`. More info [here](https://github.com/alexandre-spieser/mongodb-generic-repository/issues/7).
# Usage examples # Usage examples
This repository is meant to be inherited from. This repository is meant to be inherited from.