diff --git a/CoreIntegrationTests/CoreIntegrationTests.csproj b/CoreIntegrationTests/CoreIntegrationTests.csproj
index 115d4aa..1d7ff56 100644
--- a/CoreIntegrationTests/CoreIntegrationTests.csproj
+++ b/CoreIntegrationTests/CoreIntegrationTests.csproj
@@ -8,7 +8,7 @@
-
+
all
diff --git a/CoreIntegrationTests/Infrastructure/MongoDbDocumentTestBase.cs b/CoreIntegrationTests/Infrastructure/MongoDbDocumentTestBase.Main.cs
similarity index 85%
rename from CoreIntegrationTests/Infrastructure/MongoDbDocumentTestBase.cs
rename to CoreIntegrationTests/Infrastructure/MongoDbDocumentTestBase.Main.cs
index 2e2a108..98fc846 100644
--- a/CoreIntegrationTests/Infrastructure/MongoDbDocumentTestBase.cs
+++ b/CoreIntegrationTests/Infrastructure/MongoDbDocumentTestBase.Main.cs
@@ -12,7 +12,7 @@ using Xunit;
namespace CoreIntegrationTests.Infrastructure
{
- public abstract class MongoDbDocumentTestBase :
+ public abstract partial class MongoDbDocumentTestBase :
IClassFixture>
where T : TestDoc, new()
{
@@ -347,160 +347,6 @@ namespace CoreIntegrationTests.Infrastructure
#endregion Read
- #region Update
-
- [Fact]
- public void UpdateOne()
- {
- // Arrange
- var document = CreateTestDocument();
- SUT.AddOne(document);
- var content = GetContent();
- document.SomeContent = content;
- // Act
- var result = SUT.UpdateOne(document);
- // Assert
- Assert.True(result);
- var updatedDocument = SUT.GetById(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(document);
- var content = GetContent();
- document.SomeContent = content;
- // Act
- var result = await SUT.UpdateOneAsync(document);
- // Assert
- Assert.True(result);
- var updatedDocument = SUT.GetById(document.Id, PartitionKey);
- Assert.True(null != updatedDocument, GetTestName());
- Assert.True(content == updatedDocument.SomeContent, GetTestName());
- }
-
- [Fact]
- public void UpdateOneField()
- {
- // Arrange
- var document = CreateTestDocument();
- SUT.AddOne(document);
- var content = GetContent();
- // Act
- var result = SUT.UpdateOne(document, x => x.SomeContent, content);
- // Assert
- Assert.True(result, GetTestName());
- var updatedDocument = SUT.GetById(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(document);
- var content = GetContent();
- // Act
- var result = await SUT.UpdateOneAsync(document, x => x.SomeContent, content);
- // Assert
- Assert.True(result, GetTestName());
- var updatedDocument = SUT.GetById(document.Id, PartitionKey);
- Assert.True(null != updatedDocument, GetTestName());
- Assert.True(content == updatedDocument.SomeContent, GetTestName());
- }
-
- [Fact]
- public void UpdateOneFieldWithFilter()
- {
- // Arrange
- var document = CreateTestDocument();
- SUT.AddOne(document);
- var content = GetContent();
- // Act
- var result = SUT.UpdateOne(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
- // Assert
- Assert.True(result, GetTestName());
- var updatedDocument = SUT.GetById(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(document);
- var content = GetContent();
- // Act
- var result = await SUT.UpdateOneAsync(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
- // Assert
- Assert.True(result, GetTestName());
- var updatedDocument = SUT.GetById(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(document);
- var childrenToAdd = new List
- {
- new Child("testType1", "testValue1"),
- new Child("testType2", "testValue2")
- };
-
- var updateDef = MongoDB.Driver.Builders.Update.AddToSetEach(p => p.Children, childrenToAdd);
-
- // Act
- var result = await SUT.UpdateOneAsync(document, updateDef);
- // Assert
- Assert.True(result);
- var updatedDocument = SUT.GetById(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(document);
- var childrenToAdd = new List
- {
- new Child("testType1", "testValue1"),
- new Child("testType2", "testValue2")
- };
-
- var updateDef = MongoDB.Driver.Builders.Update.AddToSetEach(p => p.Children, childrenToAdd);
-
- // Act
- var result = SUT.UpdateOne(document, updateDef);
- // Assert
- Assert.True(result);
- var updatedDocument = SUT.GetById(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
[Fact]
diff --git a/CoreIntegrationTests/Infrastructure/MongoDbDocumentTestBase.Update.cs b/CoreIntegrationTests/Infrastructure/MongoDbDocumentTestBase.Update.cs
new file mode 100644
index 0000000..465ce1b
--- /dev/null
+++ b/CoreIntegrationTests/Infrastructure/MongoDbDocumentTestBase.Update.cs
@@ -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 :
+ IClassFixture>
+ where T : TestDoc, new()
+ {
+ #region Update One
+
+ [Fact]
+ public void UpdateOne()
+ {
+ // Arrange
+ var document = CreateTestDocument();
+ SUT.AddOne(document);
+ var content = GetContent();
+ document.SomeContent = content;
+ // Act
+ var result = SUT.UpdateOne(document);
+ // Assert
+ Assert.True(result);
+ var updatedDocument = SUT.GetById(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(document);
+ var content = GetContent();
+ document.SomeContent = content;
+ // Act
+ var result = await SUT.UpdateOneAsync(document);
+ // Assert
+ Assert.True(result);
+ var updatedDocument = SUT.GetById(document.Id, PartitionKey);
+ Assert.True(null != updatedDocument, GetTestName());
+ Assert.True(content == updatedDocument.SomeContent, GetTestName());
+ }
+
+ [Fact]
+ public void UpdateOneField()
+ {
+ // Arrange
+ var document = CreateTestDocument();
+ SUT.AddOne(document);
+ var content = GetContent();
+ // Act
+ var result = SUT.UpdateOne(document, x => x.SomeContent, content);
+ // Assert
+ Assert.True(result, GetTestName());
+ var updatedDocument = SUT.GetById(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(document);
+ var content = GetContent();
+ // Act
+ var result = await SUT.UpdateOneAsync(document, x => x.SomeContent, content);
+ // Assert
+ Assert.True(result, GetTestName());
+ var updatedDocument = SUT.GetById(document.Id, PartitionKey);
+ Assert.True(null != updatedDocument, GetTestName());
+ Assert.True(content == updatedDocument.SomeContent, GetTestName());
+ }
+
+ [Fact]
+ public void UpdateOneFieldWithFilter()
+ {
+ // Arrange
+ var document = CreateTestDocument();
+ SUT.AddOne(document);
+ var content = GetContent();
+ // Act
+ var result = SUT.UpdateOne(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
+ // Assert
+ Assert.True(result, GetTestName());
+ var updatedDocument = SUT.GetById(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(document);
+ var content = GetContent();
+ // Act
+ var result = await SUT.UpdateOneAsync(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
+ // Assert
+ Assert.True(result, GetTestName());
+ var updatedDocument = SUT.GetById(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(document);
+ var childrenToAdd = new List
+ {
+ new Child("testType1", "testValue1"),
+ new Child("testType2", "testValue2")
+ };
+
+ var updateDef = MongoDB.Driver.Builders.Update.AddToSetEach(p => p.Children, childrenToAdd);
+
+ // Act
+ var result = await SUT.UpdateOneAsync(document, updateDef);
+ // Assert
+ Assert.True(result);
+ var updatedDocument = SUT.GetById(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(document);
+ var childrenToAdd = new List
+ {
+ new Child("testType1", "testValue1"),
+ new Child("testType2", "testValue2")
+ };
+
+ var updateDef = MongoDB.Driver.Builders.Update.AddToSetEach(p => p.Children, childrenToAdd);
+
+ // Act
+ var result = SUT.UpdateOne(document, updateDef);
+ // Assert
+ Assert.True(result);
+ var updatedDocument = SUT.GetById(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(documents);
+ var docIds = documents.Select(u => u.Id).ToArray();
+ var content = GetContent();
+ // Act
+ var result = await SUT.UpdateManyAsync(x => docIds.Contains(x.Id), x => x.SomeContent, content, PartitionKey);
+ // Assert
+ Assert.True(result == 2, GetTestName());
+ var updatedDocument = SUT.GetAll(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(documents);
+ var docIds = documents.Select(u => u.Id).ToArray();
+ var filterDefinition = Builders.Filter.Where(x => docIds.Contains(x.Id));
+ var content = GetContent();
+ // Act
+ var result = await SUT.UpdateManyAsync(filterDefinition, x => x.SomeContent, content, PartitionKey);
+ // Assert
+ Assert.True(result == 2, GetTestName());
+ var updatedDocument = SUT.GetAll(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(documents);
+ var docIds = documents.Select(u => u.Id).ToArray();
+ var childrenToAdd = new List
+ {
+ new Child("testType1", "testValue1"),
+ new Child("testType2", "testValue2")
+ };
+
+ var updateDef = Builders.Update.AddToSetEach(p => p.Children, childrenToAdd);
+ var content = GetContent();
+ // Act
+ var result = await SUT.UpdateManyAsync(x => docIds.Contains(x.Id), updateDef, PartitionKey);
+ // Assert
+ Assert.True(result == 2, GetTestName());
+ var updatedDocuments = SUT.GetAll(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(documents);
+ var childrenToAdd = new List
+ {
+ new Child("testType1", "testValue1"),
+ new Child("testType2", "testValue2")
+ };
+
+ var updateDef = Builders.Update.AddToSetEach(p => p.Children, childrenToAdd);
+
+ var docIds = documents.Select(u => u.Id).ToArray();
+ var filterDefinition = Builders.Filter.Where(x => docIds.Contains(x.Id));
+ var content = GetContent();
+ // Act
+ var result = await SUT.UpdateManyAsync(filterDefinition, updateDef, PartitionKey);
+ // Assert
+ Assert.True(result == 2, GetTestName());
+ var updatedDocuments = SUT.GetAll(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(documents);
+ var docIds = documents.Select(u => u.Id).ToArray();
+ var content = GetContent();
+ // Act
+ var result = SUT.UpdateMany(x => docIds.Contains(x.Id), x => x.SomeContent, content, PartitionKey);
+ // Assert
+ Assert.True(result == 2, GetTestName());
+ var updatedDocument = SUT.GetAll(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(documents);
+ var docIds = documents.Select(u => u.Id).ToArray();
+ var filterDefinition = Builders.Filter.Where(x => docIds.Contains(x.Id));
+ var content = GetContent();
+ // Act
+ var result = SUT.UpdateMany(filterDefinition, x => x.SomeContent, content, PartitionKey);
+ // Assert
+ Assert.True(result == 2, GetTestName());
+ var updatedDocument = SUT.GetAll(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(documents);
+ var docIds = documents.Select(u => u.Id).ToArray();
+ var childrenToAdd = new List
+ {
+ new Child("testType1", "testValue1"),
+ new Child("testType2", "testValue2")
+ };
+
+ var updateDef = Builders.Update.AddToSetEach(p => p.Children, childrenToAdd);
+ var content = GetContent();
+ // Act
+ var result = SUT.UpdateMany(x => docIds.Contains(x.Id), updateDef, PartitionKey);
+ // Assert
+ Assert.True(result == 2, GetTestName());
+ var updatedDocuments = SUT.GetAll(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(documents);
+ var childrenToAdd = new List
+ {
+ new Child("testType1", "testValue1"),
+ new Child("testType2", "testValue2")
+ };
+
+ var updateDef = Builders.Update.AddToSetEach(p => p.Children, childrenToAdd);
+
+ var docIds = documents.Select(u => u.Id).ToArray();
+ var filterDefinition = Builders.Filter.Where(x => docIds.Contains(x.Id));
+ var content = GetContent();
+ // Act
+ var result = SUT.UpdateMany(filterDefinition, updateDef, PartitionKey);
+ // Assert
+ Assert.True(result == 2, GetTestName());
+ var updatedDocuments = SUT.GetAll(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
+ }
+}
diff --git a/CoreIntegrationTests/Infrastructure/MongoDbTKeyDocumentTestBase.cs b/CoreIntegrationTests/Infrastructure/MongoDbTKeyDocumentTestBase.Main.cs
similarity index 86%
rename from CoreIntegrationTests/Infrastructure/MongoDbTKeyDocumentTestBase.cs
rename to CoreIntegrationTests/Infrastructure/MongoDbTKeyDocumentTestBase.Main.cs
index 5414e48..ddd8ff9 100644
--- a/CoreIntegrationTests/Infrastructure/MongoDbTKeyDocumentTestBase.cs
+++ b/CoreIntegrationTests/Infrastructure/MongoDbTKeyDocumentTestBase.Main.cs
@@ -12,7 +12,7 @@ using Xunit;
namespace CoreIntegrationTests.Infrastructure
{
- public abstract class MongoDbTKeyDocumentTestBase :
+ public abstract partial class MongoDbTKeyDocumentTestBase :
IClassFixture>
where T : TestDoc, new()
where TKey : IEquatable
@@ -348,160 +348,6 @@ namespace CoreIntegrationTests.Infrastructure
#endregion Read
- #region Update
-
- [Fact]
- public void UpdateOne()
- {
- // Arrange
- var document = CreateTestDocument();
- SUT.AddOne(document);
- var content = GetContent();
- document.SomeContent = content;
- // Act
- var result = SUT.UpdateOne(document);
- // Assert
- Assert.True(result);
- var updatedDocument = SUT.GetById(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(document);
- var content = GetContent();
- document.SomeContent = content;
- // Act
- var result = await SUT.UpdateOneAsync(document);
- // Assert
- Assert.True(result);
- var updatedDocument = SUT.GetById(document.Id, PartitionKey);
- Assert.True(null != updatedDocument, GetTestName());
- Assert.True(content == updatedDocument.SomeContent, GetTestName());
- }
-
- [Fact]
- public void UpdateOneField()
- {
- // Arrange
- var document = CreateTestDocument();
- SUT.AddOne(document);
- var content = GetContent();
- // Act
- var result = SUT.UpdateOne(document, x => x.SomeContent, content);
- // Assert
- Assert.True(result, GetTestName());
- var updatedDocument = SUT.GetById(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(document);
- var content = GetContent();
- // Act
- var result = await SUT.UpdateOneAsync(document, x => x.SomeContent, content);
- // Assert
- Assert.True(result, GetTestName());
- var updatedDocument = SUT.GetById(document.Id, PartitionKey);
- Assert.True(null != updatedDocument, GetTestName());
- Assert.True(content == updatedDocument.SomeContent, GetTestName());
- }
-
- [Fact]
- public void UpdateOneFieldWithFilter()
- {
- // Arrange
- var document = CreateTestDocument();
- SUT.AddOne(document);
- var content = GetContent();
- // Act
- var result = SUT.UpdateOne(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
- // Assert
- Assert.True(result, GetTestName());
- var updatedDocument = SUT.GetById(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(document);
- var content = GetContent();
- // Act
- var result = await SUT.UpdateOneAsync(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
- // Assert
- Assert.True(result, GetTestName());
- var updatedDocument = SUT.GetById(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(document);
- var childrenToAdd = new List
- {
- new Child("testType1", "testValue1"),
- new Child("testType2", "testValue2")
- };
-
- var updateDef = MongoDB.Driver.Builders.Update.AddToSetEach(p => p.Children, childrenToAdd);
-
- // Act
- var result = await SUT.UpdateOneAsync(document, updateDef);
- // Assert
- Assert.True(result);
- var updatedDocument = SUT.GetById(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(document);
- var childrenToAdd = new List
- {
- new Child("testType1", "testValue1"),
- new Child("testType2", "testValue2")
- };
-
- var updateDef = MongoDB.Driver.Builders.Update.AddToSetEach(p => p.Children, childrenToAdd);
-
- // Act
- var result = SUT.UpdateOne(document, updateDef);
- // Assert
- Assert.True(result);
- var updatedDocument = SUT.GetById(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
[Fact]
diff --git a/CoreIntegrationTests/Infrastructure/MongoDbTKeyDocumentTestBase.Update.cs b/CoreIntegrationTests/Infrastructure/MongoDbTKeyDocumentTestBase.Update.cs
new file mode 100644
index 0000000..568066a
--- /dev/null
+++ b/CoreIntegrationTests/Infrastructure/MongoDbTKeyDocumentTestBase.Update.cs
@@ -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 :
+ IClassFixture>
+ where T : TestDoc, new()
+ where TKey : IEquatable
+
+ {
+ #region Update One
+
+ [Fact]
+ public void UpdateOne()
+ {
+ // Arrange
+ var document = CreateTestDocument();
+ SUT.AddOne(document);
+ var content = GetContent();
+ document.SomeContent = content;
+ // Act
+ var result = SUT.UpdateOne(document);
+ // Assert
+ Assert.True(result);
+ var updatedDocument = SUT.GetById(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(document);
+ var content = GetContent();
+ document.SomeContent = content;
+ // Act
+ var result = await SUT.UpdateOneAsync(document);
+ // Assert
+ Assert.True(result);
+ var updatedDocument = SUT.GetById(document.Id, PartitionKey);
+ Assert.True(null != updatedDocument, GetTestName());
+ Assert.True(content == updatedDocument.SomeContent, GetTestName());
+ }
+
+ [Fact]
+ public void UpdateOneField()
+ {
+ // Arrange
+ var document = CreateTestDocument();
+ SUT.AddOne(document);
+ var content = GetContent();
+ // Act
+ var result = SUT.UpdateOne(document, x => x.SomeContent, content);
+ // Assert
+ Assert.True(result, GetTestName());
+ var updatedDocument = SUT.GetById(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(document);
+ var content = GetContent();
+ // Act
+ var result = await SUT.UpdateOneAsync(document, x => x.SomeContent, content);
+ // Assert
+ Assert.True(result, GetTestName());
+ var updatedDocument = SUT.GetById(document.Id, PartitionKey);
+ Assert.True(null != updatedDocument, GetTestName());
+ Assert.True(content == updatedDocument.SomeContent, GetTestName());
+ }
+
+ [Fact]
+ public void UpdateOneFieldWithFilter()
+ {
+ // Arrange
+ var document = CreateTestDocument();
+ SUT.AddOne(document);
+ var content = GetContent();
+ // Act
+ var result = SUT.UpdateOne(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
+ // Assert
+ Assert.True(result, GetTestName());
+ var updatedDocument = SUT.GetById(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(document);
+ var content = GetContent();
+ // Act
+ var result = await SUT.UpdateOneAsync(x => x.Id.Equals(document.Id), x => x.SomeContent, content, PartitionKey);
+ // Assert
+ Assert.True(result, GetTestName());
+ var updatedDocument = SUT.GetById(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(document);
+ var childrenToAdd = new List
+ {
+ new Child("testType1", "testValue1"),
+ new Child("testType2", "testValue2")
+ };
+
+ var updateDef = MongoDB.Driver.Builders.Update.AddToSetEach(p => p.Children, childrenToAdd);
+
+ // Act
+ var result = await SUT.UpdateOneAsync(document, updateDef);
+ // Assert
+ Assert.True(result);
+ var updatedDocument = SUT.GetById(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(document);
+ var childrenToAdd = new List
+ {
+ new Child("testType1", "testValue1"),
+ new Child("testType2", "testValue2")
+ };
+
+ var updateDef = MongoDB.Driver.Builders.Update.AddToSetEach(p => p.Children, childrenToAdd);
+
+ // Act
+ var result = SUT.UpdateOne(document, updateDef);
+ // Assert
+ Assert.True(result);
+ var updatedDocument = SUT.GetById(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(documents);
+ var docIds = documents.Select(u => u.Id).ToArray();
+ var content = GetContent();
+ // Act
+ var result = await SUT.UpdateManyAsync(x => docIds.Contains(x.Id), x => x.SomeContent, content, PartitionKey);
+ // Assert
+ Assert.True(result == 2, GetTestName());
+ var updatedDocument = SUT.GetAll(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(documents);
+ var docIds = documents.Select(u => u.Id).ToArray();
+ var filterDefinition = Builders.Filter.Where(x => docIds.Contains(x.Id));
+ var content = GetContent();
+ // Act
+ var result = await SUT.UpdateManyAsync(filterDefinition, x => x.SomeContent, content, PartitionKey);
+ // Assert
+ Assert.True(result == 2, GetTestName());
+ var updatedDocument = SUT.GetAll(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(documents);
+ var docIds = documents.Select(u => u.Id).ToArray();
+ var childrenToAdd = new List
+ {
+ new Child("testType1", "testValue1"),
+ new Child("testType2", "testValue2")
+ };
+
+ var updateDef = Builders.Update.AddToSetEach(p => p.Children, childrenToAdd);
+ var content = GetContent();
+ // Act
+ var result = await SUT.UpdateManyAsync(x => docIds.Contains(x.Id), updateDef, PartitionKey);
+ // Assert
+ Assert.True(result == 2, GetTestName());
+ var updatedDocuments = SUT.GetAll(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(documents);
+ var childrenToAdd = new List
+ {
+ new Child("testType1", "testValue1"),
+ new Child("testType2", "testValue2")
+ };
+
+ var updateDef = Builders.Update.AddToSetEach(p => p.Children, childrenToAdd);
+
+ var docIds = documents.Select(u => u.Id).ToArray();
+ var filterDefinition = Builders.Filter.Where(x => docIds.Contains(x.Id));
+ var content = GetContent();
+ // Act
+ var result = await SUT.UpdateManyAsync(filterDefinition, updateDef, PartitionKey);
+ // Assert
+ Assert.True(result == 2, GetTestName());
+ var updatedDocuments = SUT.GetAll(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(documents);
+ var docIds = documents.Select(u => u.Id).ToArray();
+ var content = GetContent();
+ // Act
+ var result = SUT.UpdateMany(x => docIds.Contains(x.Id), x => x.SomeContent, content, PartitionKey);
+ // Assert
+ Assert.True(result == 2, GetTestName());
+ var updatedDocument = SUT.GetAll(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(documents);
+ var docIds = documents.Select(u => u.Id).ToArray();
+ var filterDefinition = Builders.Filter.Where(x => docIds.Contains(x.Id));
+ var content = GetContent();
+ // Act
+ var result = SUT.UpdateMany(filterDefinition, x => x.SomeContent, content, PartitionKey);
+ // Assert
+ Assert.True(result == 2, GetTestName());
+ var updatedDocument = SUT.GetAll(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(documents);
+ var docIds = documents.Select(u => u.Id).ToArray();
+ var childrenToAdd = new List
+ {
+ new Child("testType1", "testValue1"),
+ new Child("testType2", "testValue2")
+ };
+
+ var updateDef = Builders.Update.AddToSetEach(p => p.Children, childrenToAdd);
+ var content = GetContent();
+ // Act
+ var result = SUT.UpdateMany(x => docIds.Contains(x.Id), updateDef, PartitionKey);
+ // Assert
+ Assert.True(result == 2, GetTestName());
+ var updatedDocuments = SUT.GetAll(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(documents);
+ var childrenToAdd = new List
+ {
+ new Child("testType1", "testValue1"),
+ new Child("testType2", "testValue2")
+ };
+
+ var updateDef = Builders.Update.AddToSetEach(p => p.Children, childrenToAdd);
+
+ var docIds = documents.Select(u => u.Id).ToArray();
+ var filterDefinition = Builders.Filter.Where(x => docIds.Contains(x.Id));
+ var content = GetContent();
+ // Act
+ var result = SUT.UpdateMany(filterDefinition, updateDef, PartitionKey);
+ // Assert
+ Assert.True(result == 2, GetTestName());
+ var updatedDocuments = SUT.GetAll(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
+ }
+}
diff --git a/IntegrationTests/IntegrationTests.csproj b/IntegrationTests/IntegrationTests.csproj
index 7d7a821..3bfc2da 100644
--- a/IntegrationTests/IntegrationTests.csproj
+++ b/IntegrationTests/IntegrationTests.csproj
@@ -49,8 +49,8 @@
..\packages\MongoDB.Driver.Core.2.9.3\lib\net452\MongoDB.Driver.Core.dll
-
- ..\packages\MongoDbGenericRepository.1.4.3\lib\net452\MongoDbGenericRepository.dll
+
+ ..\packages\MongoDbGenericRepository.1.4.4\lib\net452\MongoDbGenericRepository.dll
..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll
diff --git a/IntegrationTests/packages.config b/IntegrationTests/packages.config
index 051c393..5b90bd2 100644
--- a/IntegrationTests/packages.config
+++ b/IntegrationTests/packages.config
@@ -5,7 +5,7 @@
-
+
diff --git a/MongoDbGenericRepository.v3.ncrunchsolution.user b/MongoDbGenericRepository.v3.ncrunchsolution.user
deleted file mode 100644
index b82f7a5..0000000
--- a/MongoDbGenericRepository.v3.ncrunchsolution.user
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- Run all tests automatically [Global]
-
-
\ No newline at end of file
diff --git a/MongoDbGenericRepository/Abstractions/IBaseMongoRepository_Update.cs b/MongoDbGenericRepository/Abstractions/IBaseMongoRepository_Update.cs
index 878fdb7..d30bc5c 100644
--- a/MongoDbGenericRepository/Abstractions/IBaseMongoRepository_Update.cs
+++ b/MongoDbGenericRepository/Abstractions/IBaseMongoRepository_Update.cs
@@ -131,5 +131,109 @@ namespace MongoDbGenericRepository
bool UpdateOne(FilterDefinition filter, Expression> field, TField value, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
+
+ ///
+ /// For the entities selected by the filter, updates the property field with the given value.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The partition key for the document.
+ Task UpdateManyAsync(Expression> filter, Expression> field, TField value, string partitionKey = null)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entities selected by the filter, updates the property field with the given value.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The value of the partition key.
+ Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey = null)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entities selected by the filter, applies the update you have defined in MongoDb.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The document filter.
+ /// The update definition to apply.
+ /// The value of the partition key.
+ Task UpdateManyAsync(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey = null)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entities selected by the filter, applies the update you have defined in MongoDb.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The document filter.
+ /// The update definition to apply.
+ /// The value of the partition key.
+ Task UpdateManyAsync(Expression> filter, UpdateDefinition updateDefinition, string partitionKey = null)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entities selected by the filter, updates the property field with the given value.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The partition key for the document.
+ long UpdateMany(Expression> filter, Expression> field, TField value, string partitionKey = null)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entities selected by the filter, updates the property field with the given value.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The value of the partition key.
+ long UpdateMany(FilterDefinition filter, Expression> field, TField value, string partitionKey = null)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entities selected by the filter, applies the update you have defined in MongoDb.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The document filter.
+ /// The update definition to apply.
+ /// The value of the partition key.
+ long UpdateMany(Expression> filter, UpdateDefinition updateDefinition, string partitionKey = null)
+ where TDocument : IDocument
+ where TKey : IEquatable;
+
+ ///
+ /// For the entities selected by the filter, applies the update you have defined in MongoDb.
+ ///
+ /// The type representing a Document.
+ /// The type of the primary key for a Document.
+ /// The document filter.
+ /// The update definition to apply.
+ /// The value of the partition key.
+ long UpdateMany(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey = null)
+ where TDocument : IDocument
+ where TKey : IEquatable;
}
}
diff --git a/MongoDbGenericRepository/BaseMongoRepository.Update.cs b/MongoDbGenericRepository/BaseMongoRepository.Update.cs
index 61696a7..82306b1 100644
--- a/MongoDbGenericRepository/BaseMongoRepository.Update.cs
+++ b/MongoDbGenericRepository/BaseMongoRepository.Update.cs
@@ -168,6 +168,119 @@ namespace MongoDbGenericRepository
return await MongoDbUpdater.UpdateOneAsync(filter, field, value, partitionKey);
}
+ ///
+ /// For the entities selected by the filter, updates the property field with the given value.
+ ///
+ /// The type representing a Document.
+ /// The type of the field.
+ /// The document filter.
+ /// The field selector.
+ /// The new value of the property field.
+ /// The value of the partition key.
+ public virtual async Task UpdateManyAsync(FilterDefinition filter, Expression