Compare commits

..

19 Commits

Author SHA1 Message Date
alexandre-spieser 0cf24b1dcf integration tested index management functionality 2018-10-07 19:05:59 +01:00
alexandre-spieser fd8f98e375 adding more tests 2018-10-01 22:31:08 +01:00
alexandre-spieser fa6687c084 fixed test by adding semaphores. Also reduced collections name to avoid hitting the 127 byte limit regarding index names. 2018-09-30 19:26:25 +01:00
alexandre-spieser 0b939592ba Implementation of index management.CreateTextIndexWithOptionAsync is failing. 2018-09-30 19:07:38 +01:00
alexandre-spieser ad18170804 work on indexes continued 2018-09-17 22:39:14 +01:00
alexandre-spieser 099e16a88c prep work on indexes methods 2018-09-17 08:41:36 +01:00
alexandre-spieser e41a73f745 1.3.7 release 2018-09-09 18:55:53 +01:00
alexandre-spieser 526adf0a23 remove unused using statements 2018-09-09 13:31:42 +01:00
alexandre-spieser db4061dc3c cleanup. Removing redundant GetCollection and Drop collection method, removed static constructor, added a virtual initialization method. 2018-09-09 13:05:45 +01:00
alexandre-spieser 72ea6e7999 clean up + full support for bulk insertion and deletion of documents of the same type but with different partitionkey values 2018-09-09 12:14:43 +01:00
alexandre-spieser 7f126a098d support insertion of documents with different PartitionKey values 2018-09-03 21:46:30 +01:00
alexandre-spieser 456af09a84 + Upgraded packages
+ Added GetByMax, GetByMaxAsync, GetByMin, GetByMinAsync, GetMaxValue and GetMaxValueAsync Methods (GetMinValue and GetMinValueAsync will come in another PR)
+ Added tests
2018-08-05 21:10:41 +01:00
Alexandre SPIESER f0af32adca Update copyright year to 2018 2018-05-11 22:53:43 +01:00
alexandre-spieser 345fca2e6e Added summary where needed. 2018-03-06 23:11:33 +00:00
alexandre-spieser 57d332ef2a Add support for ObjectId type for the Id of the document. 2018-03-05 23:07:56 +00:00
Alexandre SPIESER 2f6515a809 Merge pull request #3 from alexandre-spieser/add-license-1
Create LICENSE
2018-02-24 12:22:58 +00:00
Alexandre SPIESER 82dc2f2024 Create LICENSE 2018-02-24 12:22:49 +00:00
Alexandre SPIESER bc992e8c61 Update README.md 2018-02-16 15:11:09 +00:00
Alexandre SPIESER 47e85f1760 Update README.md 2018-02-16 15:10:18 +00:00
41 changed files with 4150 additions and 406 deletions
+22
View File
@@ -0,0 +1,22 @@
using CoreIntegrationTests.Infrastructure;
using MongoDB.Bson;
using System;
namespace CoreIntegrationTests
{
public class CoreObjectIdTestDocument : TestDoc<ObjectId>
{
}
public class CRUDObjectIdTests : MongoDbTKeyDocumentTestBase<CoreObjectIdTestDocument, ObjectId>
{
public CRUDObjectIdTests(MongoDbTestFixture<CoreObjectIdTestDocument, ObjectId> fixture) : base(fixture)
{
}
public override string GetClassName()
{
return "CRUDObjectIdTests";
}
}
}
@@ -5,7 +5,7 @@ using System;
namespace CoreIntegrationTests
{
[CollectionName("CoreTestingCollectionNameAttributePartitionedTKey")]
[CollectionName("CoreTestingCNameAttrPart")]
public class CorePartitionedCollectionNameDoc : TestDoc, IPartitionedDocument
{
public CorePartitionedCollectionNameDoc()
@@ -18,7 +18,6 @@ namespace CoreIntegrationTests
{
public CRUDPartitionedTests(MongoDbTestFixture<CorePartitionedDoc, Guid> fixture) : base(fixture)
{
}
public override string GetClassName()
@@ -5,7 +5,7 @@ using System;
namespace CoreIntegrationTests
{
[CollectionName("TestingCollectionNameAttributePartitionedTKey")]
[CollectionName("TestingCNameAttrPartTKey")]
public class CoreTKeyPartitionedCollectionNameDoc : TestDoc<Guid>, IPartitionedDocument
{
public CoreTKeyPartitionedCollectionNameDoc()
@@ -5,14 +5,14 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="2.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="MongoDB.Driver" Version="2.5.0" />
<PackageReference Include="MongoDbGenericRepository" Version="1.3.5" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.console" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.1.2" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="2.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="MongoDB.Driver" Version="2.7.0" />
<PackageReference Include="MongoDbGenericRepository" Version="1.3.8" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.console" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta4-build3742" />
</ItemGroup>
+1 -1
View File
@@ -6,7 +6,7 @@ using Xunit;
using Microsoft.AspNetCore.Identity;
using System.Threading.Tasks;
namespace CoreCoreIntegrationTests
namespace CoreIntegrationTests
{
public class MongoIdentityUser<TKey> : IdentityUser<TKey>, IDocument<TKey>
where TKey : IEquatable<TKey>
@@ -1,6 +1,4 @@
using CoreCoreIntegrationTests;
using MongoDB.Bson.Serialization;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Bson.Serialization.Conventions;
using System.Threading;
namespace CoreIntegrationTests.Infrastructure
@@ -3,7 +3,9 @@ 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;
@@ -11,7 +13,7 @@ namespace CoreIntegrationTests.Infrastructure
{
public abstract class MongoDbDocumentTestBase<T> :
IClassFixture<MongoDbTestFixture<T, Guid>>
where T: TestDoc, new()
where T : TestDoc, new()
{
private readonly MongoDbTestFixture<T, Guid> _fixture;
@@ -88,7 +90,7 @@ namespace CoreIntegrationTests.Infrastructure
// Assert
long count = string.IsNullOrEmpty(PartitionKey) ? SUT.Count<T>(e => e.Id.Equals(document.Id))
: SUT.Count<T>(e => e.Id.Equals(document.Id), PartitionKey);
Assert.True (1 == count, GetTestName());
Assert.True(1 == count, GetTestName());
}
[Fact]
@@ -103,7 +105,33 @@ namespace CoreIntegrationTests.Infrastructure
|| e.Id.Equals(documents[1].Id))
: SUT.Count<T>(e => e.Id.Equals(documents[0].Id)
|| e.Id.Equals(documents[1].Id), PartitionKey);
Assert.True (2 == count, GetTestName());
Assert.True(2 == count, GetTestName());
}
[Fact]
public void AddManyWithDifferentPartitionKey()
{
// only run this test for tests on documents with partition key
if (!string.IsNullOrEmpty(PartitionKey))
{
// Arrange
var documents = new List<T> { new T(), new T(), new T(), new T() };
if (documents.Any(e => e is IPartitionedDocument))
{
var secondPartitionKey = $"{PartitionKey}-2";
((IPartitionedDocument)documents[2]).PartitionKey = secondPartitionKey;
((IPartitionedDocument)documents[3]).PartitionKey = secondPartitionKey;
// Act
SUT.AddMany<T>(documents);
// Assert
long count = SUT.Count<T>(e => e.Id.Equals(documents[0].Id) || e.Id.Equals(documents[1].Id), PartitionKey);
long secondPartitionCount = SUT.Count<T>(e => e.Id.Equals(documents[2].Id) || e.Id.Equals(documents[3].Id), secondPartitionKey);
// Cleanup second partition
SUT.DeleteMany<T>(e => e.Id.Equals(documents[2].Id) || e.Id.Equals(documents[3].Id), secondPartitionKey);
Assert.True(2 == count, GetTestName());
Assert.True(2 == secondPartitionCount, GetTestName());
}
}
}
[Fact]
@@ -118,9 +146,34 @@ namespace CoreIntegrationTests.Infrastructure
|| e.Id.Equals(documents[1].Id))
: SUT.Count<T>(e => e.Id.Equals(documents[0].Id)
|| e.Id.Equals(documents[1].Id), PartitionKey);
Assert.True (2 == count, GetTestName());
Assert.True(2 == count, GetTestName());
}
[Fact]
public async Task AddManyAsyncWithDifferentPartitionKey()
{
// only run this test for tests on documents with partition key
if (!string.IsNullOrEmpty(PartitionKey))
{
// Arrange
var documents = new List<T> { new T(), new T(), new T(), new T() };
if (documents.Any(e => e is IPartitionedDocument))
{
var secondPartitionKey = $"{PartitionKey}-2";
((IPartitionedDocument)documents[2]).PartitionKey = secondPartitionKey;
((IPartitionedDocument)documents[3]).PartitionKey = secondPartitionKey;
// Act
await SUT.AddManyAsync<T>(documents);
// Assert
long count = SUT.Count<T>(e => e.Id.Equals(documents[0].Id) || e.Id.Equals(documents[1].Id), PartitionKey);
long secondPartitionCount = SUT.Count<T>(e => e.Id.Equals(documents[2].Id) || e.Id.Equals(documents[3].Id), secondPartitionKey);
// Cleanup second partition
SUT.DeleteMany<T>(e => e.Id.Equals(documents[2].Id) || e.Id.Equals(documents[3].Id), secondPartitionKey);
Assert.True(2 == count, GetTestName());
Assert.True(2 == secondPartitionCount, GetTestName());
}
}
}
#endregion Add
@@ -184,7 +237,7 @@ namespace CoreIntegrationTests.Infrastructure
var cursor = SUT.GetCursor<T>(x => x.Id.Equals(document.Id), PartitionKey);
var count = cursor.Count();
// Assert
Assert.True (1 == count, GetTestName());
Assert.True(1 == count, GetTestName());
}
[Fact]
@@ -439,10 +492,10 @@ namespace CoreIntegrationTests.Infrastructure
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());
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
@@ -458,7 +511,7 @@ namespace CoreIntegrationTests.Infrastructure
// Act
var result = SUT.DeleteOne<T>(document);
// Assert
Assert.True (1 == result);
Assert.True(1 == result);
Assert.False(SUT.Any<T>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
}
@@ -471,7 +524,7 @@ namespace CoreIntegrationTests.Infrastructure
// Act
var result = SUT.DeleteOne<T>(e => e.Id.Equals(document.Id), PartitionKey);
// Assert
Assert.True (1 == result);
Assert.True(1 == result);
Assert.False(SUT.Any<T>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
}
@@ -484,7 +537,7 @@ namespace CoreIntegrationTests.Infrastructure
// Act
var result = await SUT.DeleteOneAsync<T>(document);
// Assert
Assert.True (1 == result);
Assert.True(1 == result);
Assert.False(SUT.Any<T>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
}
@@ -497,7 +550,7 @@ namespace CoreIntegrationTests.Infrastructure
// Act
var result = await SUT.DeleteOneAsync<T>(e => e.Id.Equals(document.Id), PartitionKey);
// Assert
Assert.True (1 == result);
Assert.True(1 == result);
Assert.False(SUT.Any<T>(e => e.Id.Equals(document.Id), PartitionKey), GetTestName());
}
@@ -523,12 +576,25 @@ namespace CoreIntegrationTests.Infrastructure
var criteria = $"{GetTestName()}.{DocumentTypeName}";
var documents = CreateTestDocuments(5);
documents.ForEach(e => e.SomeContent = criteria);
var canPartition = !string.IsNullOrEmpty(PartitionKey) && documents.Any(e => e is IPartitionedDocument);
string secondKey = null;
if (canPartition)
{
secondKey = $"{PartitionKey}-2";
((IPartitionedDocument)documents[3]).PartitionKey = secondKey;
((IPartitionedDocument)documents[4]).PartitionKey = secondKey;
}
SUT.AddMany<T>(documents);
// Act
var result = await SUT.DeleteManyAsync<T>(documents);
// Assert
Assert.True(5 == result);
Assert.False(SUT.Any<T>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
if (canPartition)
{
Assert.False(SUT.Any<T>(e => e.SomeContent == criteria, secondKey), GetTestName());
}
}
[Fact]
@@ -553,12 +619,25 @@ namespace CoreIntegrationTests.Infrastructure
var criteria = $"{GetTestName()}.{DocumentTypeName}";
var documents = CreateTestDocuments(5);
documents.ForEach(e => e.SomeContent = criteria);
var canPartition = !string.IsNullOrEmpty(PartitionKey) && documents.Any(e => e is IPartitionedDocument);
string secondKey = null;
if (canPartition)
{
secondKey = $"{PartitionKey}-2";
((IPartitionedDocument)documents[3]).PartitionKey = secondKey;
((IPartitionedDocument)documents[4]).PartitionKey = secondKey;
}
SUT.AddMany<T>(documents);
// Act
var result = SUT.DeleteMany<T>(documents);
// Assert
Assert.True(5 == result);
Assert.False(SUT.Any<T>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
if (canPartition)
{
Assert.False(SUT.Any<T>(e => e.SomeContent == criteria, secondKey), GetTestName());
}
}
#endregion Delete
@@ -679,7 +758,325 @@ namespace CoreIntegrationTests.Infrastructure
#endregion Project
#region Max / Min Queries
[Fact]
public async Task GetByMaxAsync()
{
// Arrange
var criteria = $"{GetTestName()}.{DocumentTypeName}.{Guid.NewGuid()}";
var documents = CreateTestDocuments(5);
var i = 1;
documents.ForEach(e =>
{
e.Nested.SomeDate = e.Nested.SomeDate.AddDays(i++);
e.SomeContent = criteria;
});
SUT.AddMany<T>(documents);
var expectedMax = documents.OrderByDescending(e => e.Nested.SomeDate).First();
// Act
var result = await SUT.GetByMaxAsync<T>(e => e.SomeContent == criteria, e => e.Nested.SomeDate, PartitionKey);
// Assert
Assert.NotNull(result);
Assert.Equal(expectedMax.Id, result.Id);
}
[Fact]
public void GetByMax()
{
// Arrange
var criteria = $"{GetTestName()}.{DocumentTypeName}.{Guid.NewGuid()}";
var documents = CreateTestDocuments(5);
var i = 1;
documents.ForEach(e =>
{
e.Nested.SomeDate = e.Nested.SomeDate.AddDays(i++);
e.SomeContent = criteria;
});
SUT.AddMany<T>(documents);
var expectedMax = documents.OrderByDescending(e => e.Nested.SomeDate).First();
// Act
var result = SUT.GetByMax<T>(e => e.SomeContent == criteria, e => e.Nested.SomeDate, PartitionKey);
// Assert
Assert.NotNull(result);
Assert.Equal(expectedMax.Id, result.Id);
}
[Fact]
public async Task GetByMinAsync()
{
// Arrange
var criteria = $"{GetTestName()}.{DocumentTypeName}.{Guid.NewGuid()}";
var documents = CreateTestDocuments(5);
var i = 1;
documents.ForEach(e =>
{
e.Nested.SomeDate = e.Nested.SomeDate.AddDays(i++);
e.SomeContent = criteria;
});
SUT.AddMany<T>(documents);
var expectedMin = documents.OrderBy(e => e.Nested.SomeDate).First();
// Act
var result = await SUT.GetByMinAsync<T>(e => e.SomeContent == criteria, e => e.Nested.SomeDate, PartitionKey);
// Assert
Assert.NotNull(result);
Assert.Equal(expectedMin.Id, result.Id);
}
[Fact]
public void GetByMin()
{
// Arrange
var criteria = $"{GetTestName()}.{DocumentTypeName}.{Guid.NewGuid()}";
var documents = CreateTestDocuments(5);
var i = 1;
documents.ForEach(e =>
{
e.Nested.SomeDate = e.Nested.SomeDate.AddDays(i++);
e.SomeContent = criteria;
});
SUT.AddMany<T>(documents);
var expectedMin = documents.OrderBy(e => e.Nested.SomeDate).First();
// Act
var result = SUT.GetByMin<T>(e => e.SomeContent == criteria, e => e.Nested.SomeDate, PartitionKey);
// Assert
Assert.NotNull(result);
Assert.Equal(expectedMin.Id, result.Id);
}
[Fact]
public void GetMinValue()
{
// Arrange
var criteria = $"{GetTestName()}.{DocumentTypeName}.{Guid.NewGuid()}";
var documents = CreateTestDocuments(5);
var i = 1;
documents.ForEach(e =>
{
e.Nested.SomeDate = e.Nested.SomeDate.AddDays(i++);
e.SomeContent = criteria;
});
SUT.AddMany<T>(documents);
var expectedMin = documents.OrderBy(e => e.Nested.SomeDate).First();
// Act
var result = SUT.GetMinValue<T, DateTime>(e => e.SomeContent == criteria, e => e.Nested.SomeDate, PartitionKey);
// Assert
Assert.True(result != default(DateTime));
Assert.Equal(expectedMin.Nested.SomeDate.Date, result.Date);
}
[Fact]
public async Task GetMinValueAsync()
{
// Arrange
var criteria = $"{GetTestName()}.{DocumentTypeName}.{Guid.NewGuid()}";
var documents = CreateTestDocuments(5);
var i = 1;
documents.ForEach(e =>
{
e.Nested.SomeDate = e.Nested.SomeDate.AddDays(i++);
e.SomeContent = criteria;
});
SUT.AddMany<T>(documents);
var expectedMin = documents.OrderBy(e => e.Nested.SomeDate).First();
// Act
var result = await SUT.GetMinValueAsync<T, DateTime>(e => e.SomeContent == criteria, e => e.Nested.SomeDate, PartitionKey);
// Assert
Assert.True(result != default(DateTime));
Assert.Equal(expectedMin.Nested.SomeDate.Date, result.Date);
}
[Fact]
public void GetMaxValue()
{
// Arrange
var criteria = $"{GetTestName()}.{DocumentTypeName}.{Guid.NewGuid()}";
var documents = CreateTestDocuments(5);
var i = 1;
documents.ForEach(e =>
{
e.Nested.SomeDate = e.Nested.SomeDate.AddDays(i++);
e.SomeContent = criteria;
});
SUT.AddMany<T>(documents);
var expectedMax = documents.OrderByDescending(e => e.Nested.SomeDate).First();
// Act
var result = SUT.GetMaxValue<T, DateTime>(e => e.SomeContent == criteria, e => e.Nested.SomeDate, PartitionKey);
// Assert
Assert.True(result != default(DateTime));
Assert.Equal(expectedMax.Nested.SomeDate.Date, result.Date);
}
[Fact]
public async Task GetMaxValueAsync()
{
// Arrange
var criteria = $"{GetTestName()}.{DocumentTypeName}.{Guid.NewGuid()}";
var documents = CreateTestDocuments(5);
var i = 1;
documents.ForEach(e =>
{
e.Nested.SomeDate = e.Nested.SomeDate.AddDays(i++);
e.SomeContent = criteria;
});
SUT.AddMany<T>(documents);
var expectedMin = documents.OrderByDescending(e => e.Nested.SomeDate).First();
// Act
var result = await SUT.GetMaxValueAsync<T, DateTime>(e => e.SomeContent == criteria, e => e.Nested.SomeDate, PartitionKey);
// Assert
Assert.True(result != default(DateTime));
Assert.Equal(expectedMin.Nested.SomeDate.Date, result.Date);
}
#endregion Max / Min Queries
#region Index Management
static SemaphoreSlim textIndexSemaphore = new SemaphoreSlim(1, 1);
[Fact]
public async Task CreateTextIndexNoOptionAsync()
{
// Arrange
const string expectedIndexName = "SomeContent_text";
// Act
await textIndexSemaphore.WaitAsync();
try
{
var result = await SUT.CreateTextIndexAsync<T>(x => x.SomeContent, null, PartitionKey);
// Assert
var listOfIndexNames = await SUT.GetIndexesNamesAsync<T>(PartitionKey);
Assert.Contains(expectedIndexName, listOfIndexNames);
// Cleanup
await SUT.DropIndexAsync<T>(expectedIndexName, PartitionKey);
}
finally
{
textIndexSemaphore.Release();
}
}
[Fact]
public async Task CreateTextIndexWithOptionAsync()
{
// Arrange
string expectedIndexName = $"{Guid.NewGuid()}";
var option = new IndexCreationOptions
{
Name = expectedIndexName
};
await textIndexSemaphore.WaitAsync();
try
{
// Act
var result = await SUT.CreateTextIndexAsync<T>(x => x.AddedAtUtc, option, PartitionKey);
// Assert
var listOfIndexNames = await SUT.GetIndexesNamesAsync<T>(PartitionKey);
Assert.Contains(expectedIndexName, listOfIndexNames);
// Cleanup
await SUT.DropIndexAsync<T>(expectedIndexName, PartitionKey);
}
finally
{
textIndexSemaphore.Release();
}
}
[Fact]
public async Task CreateAscendingIndexAsync()
{
// Arrange
const string expectedIndexName = "SomeContent_1";
// Act
var result = await SUT.CreateAscendingIndexAsync<T>(x => x.SomeContent, null, PartitionKey);
// Assert
var listOfIndexNames = await SUT.GetIndexesNamesAsync<T>(PartitionKey);
Assert.Contains(expectedIndexName, listOfIndexNames);
// Cleanup
await SUT.DropIndexAsync<T>(expectedIndexName, PartitionKey);
}
[Fact]
public async Task CreateDescendingIndexAsync()
{
// Arrange
const string expectedIndexName = "SomeContent_-1";
// Act
var result = await SUT.CreateDescendingIndexAsync<T>(x => x.SomeContent, null, PartitionKey);
// Assert
var listOfIndexNames = await SUT.GetIndexesNamesAsync<T>(PartitionKey);
Assert.Contains(expectedIndexName, listOfIndexNames);
// Cleanup
await SUT.DropIndexAsync<T>(expectedIndexName, PartitionKey);
}
[Fact]
public async Task CreateHashedIndexAsync()
{
// Arrange
const string expectedIndexName = "SomeContent_hashed";
// Act
var result = await SUT.CreateHashedIndexAsync<T>(x => x.SomeContent, null, PartitionKey);
// Assert
var listOfIndexNames = await SUT.GetIndexesNamesAsync<T>(PartitionKey);
Assert.Contains(expectedIndexName, listOfIndexNames);
// Cleanup
await SUT.DropIndexAsync<T>(expectedIndexName, PartitionKey);
}
[Fact]
public async Task CreateCombinedTextIndexAsync()
{
// Arrange
const string expectedIndexName = "SomeContent2_text_SomeContent3_text";
// Act
Expression <Func<T, object>> ex = x => x.SomeContent2;
Expression <Func<T, object>> ex2 = x => x.SomeContent3;
var result = await SUT.CreateCombinedTextIndexAsync<T>(new[] { ex, ex2 }, null, PartitionKey);
// Assert
var listOfIndexNames = await SUT.GetIndexesNamesAsync<T>(PartitionKey);
Assert.Contains(expectedIndexName, listOfIndexNames);
// Cleanup
await SUT.DropIndexAsync<T>(expectedIndexName, PartitionKey);
}
#endregion Index Management
#region Test Utils
[MethodImpl(MethodImplOptions.NoInlining)]
private string GetCurrentMethod()
{
@@ -3,7 +3,9 @@ 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;
@@ -107,6 +109,32 @@ namespace CoreIntegrationTests.Infrastructure
Assert.True (2 == count, GetTestName());
}
[Fact]
public void AddManyWithDifferentPartitionKey()
{
// only run this test for tests on documents with partition key
if (!string.IsNullOrEmpty(PartitionKey))
{
// Arrange
var documents = new List<T> { new T(), new T(), new T(), new T() };
if (documents.Any(e => e is IPartitionedDocument))
{
var secondPartitionKey = $"{PartitionKey}-2";
((IPartitionedDocument)documents[2]).PartitionKey = secondPartitionKey;
((IPartitionedDocument)documents[3]).PartitionKey = secondPartitionKey;
// Act
SUT.AddMany<T, TKey>(documents);
// Assert
long count = SUT.Count<T, TKey>(e => e.Id.Equals(documents[0].Id) || e.Id.Equals(documents[1].Id), PartitionKey);
long secondPartitionCount = SUT.Count<T, TKey>(e => e.Id.Equals(documents[2].Id) || e.Id.Equals(documents[3].Id), secondPartitionKey);
// Cleanup second partition
SUT.DeleteMany<T, TKey>(e => e.Id.Equals(documents[2].Id) || e.Id.Equals(documents[3].Id), secondPartitionKey);
Assert.True(2 == count, GetTestName());
Assert.True(2 == secondPartitionCount, GetTestName());
}
}
}
[Fact]
public async Task AddManyAsync()
{
@@ -122,6 +150,31 @@ namespace CoreIntegrationTests.Infrastructure
Assert.True (2 == count, GetTestName());
}
[Fact]
public async Task AddManyAsyncWithDifferentPartitionKey()
{
// only run this test for tests on documents with partition key
if (!string.IsNullOrEmpty(PartitionKey))
{
// Arrange
var documents = new List<T> { new T(), new T(), new T(), new T() };
if (documents.Any(e => e is IPartitionedDocument))
{
var secondPartitionKey = $"{PartitionKey}-2";
((IPartitionedDocument)documents[2]).PartitionKey = secondPartitionKey;
((IPartitionedDocument)documents[3]).PartitionKey = secondPartitionKey;
// Act
await SUT.AddManyAsync<T, TKey>(documents);
// Assert
long count = SUT.Count<T, TKey>(e => e.Id.Equals(documents[0].Id) || e.Id.Equals(documents[1].Id), PartitionKey);
long secondPartitionCount = SUT.Count<T, TKey>(e => e.Id.Equals(documents[2].Id) || e.Id.Equals(documents[3].Id), secondPartitionKey);
// Cleanup second partition
SUT.DeleteMany<T, TKey>(e => e.Id.Equals(documents[2].Id) || e.Id.Equals(documents[3].Id), secondPartitionKey);
Assert.True(2 == count, GetTestName());
Assert.True(2 == secondPartitionCount, GetTestName());
}
}
}
#endregion Add
@@ -524,12 +577,25 @@ namespace CoreIntegrationTests.Infrastructure
var criteria = $"{GetTestName()}.{DocumentTypeName}";
var documents = CreateTestDocuments(5);
documents.ForEach(e => e.SomeContent = criteria);
var canPartition = !string.IsNullOrEmpty(PartitionKey) && documents.Any(e => e is IPartitionedDocument);
string secondKey = null;
if (canPartition)
{
secondKey = $"{PartitionKey}-2";
((IPartitionedDocument)documents[3]).PartitionKey = secondKey;
((IPartitionedDocument)documents[4]).PartitionKey = secondKey;
}
SUT.AddMany<T, TKey>(documents);
// Act
var result = await SUT.DeleteManyAsync<T, TKey>(documents);
// Assert
Assert.True(5 == result);
Assert.False(SUT.Any<T, TKey>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
if (canPartition)
{
Assert.False(SUT.Any<T, TKey>(e => e.SomeContent == criteria, secondKey), GetTestName());
}
}
[Fact]
@@ -554,12 +620,25 @@ namespace CoreIntegrationTests.Infrastructure
var criteria = $"{GetTestName()}.{DocumentTypeName}";
var documents = CreateTestDocuments(5);
documents.ForEach(e => e.SomeContent = criteria);
var canPartition = !string.IsNullOrEmpty(PartitionKey) && documents.Any(e => e is IPartitionedDocument);
string secondKey = null;
if (canPartition)
{
secondKey = $"{PartitionKey}-2";
((IPartitionedDocument)documents[3]).PartitionKey = secondKey;
((IPartitionedDocument)documents[4]).PartitionKey = secondKey;
}
SUT.AddMany<T, TKey>(documents);
// Act
var result = SUT.DeleteMany<T, TKey>(documents);
// Assert
Assert.True(5 == result);
Assert.False(SUT.Any<T, TKey>(e => e.SomeContent == criteria, PartitionKey), GetTestName());
if (canPartition)
{
Assert.False(SUT.Any<T, TKey>(e => e.SomeContent == criteria, secondKey), GetTestName());
}
}
#endregion Delete
@@ -680,6 +759,315 @@ namespace CoreIntegrationTests.Infrastructure
#endregion Project
#region Max / Min Queries
[Fact]
public async Task GetByMaxAsync()
{
// Arrange
var criteria = $"{GetTestName()}.{DocumentTypeName}.{Guid.NewGuid()}";
var documents = CreateTestDocuments(5);
var i = 1;
documents.ForEach(e => {
e.Nested.SomeDate = e.Nested.SomeDate.AddDays(i++);
e.SomeContent = criteria;
});
SUT.AddMany<T, TKey>(documents);
var expectedMax = documents.OrderByDescending(e => e.Nested.SomeDate).First();
// Act
var result = await SUT.GetByMaxAsync<T, TKey>(e => e.SomeContent == criteria, e => e.Nested.SomeDate, PartitionKey);
// Assert
Assert.NotNull(result);
Assert.Equal(expectedMax.Id, result.Id);
}
[Fact]
public void GetByMax()
{
// Arrange
var criteria = $"{GetTestName()}.{DocumentTypeName}.{Guid.NewGuid()}";
var documents = CreateTestDocuments(5);
var i = 1;
documents.ForEach(e => {
e.Nested.SomeDate = e.Nested.SomeDate.AddDays(i++);
e.SomeContent = criteria;
});
SUT.AddMany<T, TKey>(documents);
var expectedMax = documents.OrderByDescending(e => e.Nested.SomeDate).First();
// Act
var result = SUT.GetByMax<T, TKey>(e => e.SomeContent == criteria, e => e.Nested.SomeDate, PartitionKey);
// Assert
Assert.NotNull(result);
Assert.Equal(expectedMax.Id, result.Id);
}
[Fact]
public void GetMaxValue()
{
// Arrange
var criteria = $"{GetTestName()}.{DocumentTypeName}.{Guid.NewGuid()}";
var documents = CreateTestDocuments(5);
var i = 1;
documents.ForEach(e => {
e.Nested.SomeDate = e.Nested.SomeDate.AddDays(i++);
e.SomeContent = criteria;
});
SUT.AddMany<T, TKey>(documents);
var expectedMax = documents.OrderByDescending(e => e.Nested.SomeDate).First();
// Act
var result = SUT.GetMaxValue<T, TKey, DateTime>(e => e.SomeContent == criteria, e => e.Nested.SomeDate, PartitionKey);
// Assert
Assert.False(result == default(DateTime));
Assert.Equal(expectedMax.Nested.SomeDate.Date, result.Date);
}
[Fact]
public async Task GetMaxValueAsync()
{
// Arrange
var criteria = $"{GetTestName()}.{DocumentTypeName}.{Guid.NewGuid()}";
var documents = CreateTestDocuments(5);
var i = 1;
documents.ForEach(e => {
e.Nested.SomeDate = e.Nested.SomeDate.AddDays(i++);
e.SomeContent = criteria;
});
SUT.AddMany<T, TKey>(documents);
var expectedMax = documents.OrderByDescending(e => e.Nested.SomeDate).First();
// Act
var result = await SUT.GetMaxValueAsync<T, TKey, DateTime>(e => e.SomeContent == criteria, e => e.Nested.SomeDate, PartitionKey);
// Assert
Assert.False(result == default(DateTime));
Assert.Equal(expectedMax.Nested.SomeDate.Date, result.Date);
}
[Fact]
public async Task GetByMinAsync()
{
// Arrange
var criteria = $"{GetTestName()}.{DocumentTypeName}.{Guid.NewGuid()}";
var documents = CreateTestDocuments(5);
var i = 1;
documents.ForEach(e => {
e.Nested.SomeDate = e.Nested.SomeDate.AddDays(i++);
e.SomeContent = criteria;
});
SUT.AddMany<T, TKey>(documents);
var expectedMin = documents.OrderBy(e => e.Nested.SomeDate).First();
// Act
var result = await SUT.GetByMinAsync<T, TKey>(e => e.SomeContent == criteria, e => e.Nested.SomeDate, PartitionKey);
// Assert
Assert.NotNull(result);
Assert.Equal(expectedMin.Id, result.Id);
}
[Fact]
public void GetByMin()
{
// Arrange
var criteria = $"{GetTestName()}.{DocumentTypeName}.{Guid.NewGuid()}";
var documents = CreateTestDocuments(5);
var i = 1;
documents.ForEach(e => {
e.Nested.SomeDate = e.Nested.SomeDate.AddDays(i++);
e.SomeContent = criteria;
});
SUT.AddMany<T, TKey>(documents);
var expectedMin = documents.OrderBy(e => e.Nested.SomeDate).First();
// Act
var result = SUT.GetByMin<T, TKey>(e => e.SomeContent == criteria, e => e.Nested.SomeDate, PartitionKey);
// Assert
Assert.NotNull(result);
Assert.Equal(expectedMin.Id, result.Id);
}
[Fact]
public void GetMinValue()
{
// Arrange
var criteria = $"{GetTestName()}.{DocumentTypeName}.{Guid.NewGuid()}";
var documents = CreateTestDocuments(5);
var i = 1;
documents.ForEach(e => {
e.Nested.SomeDate = e.Nested.SomeDate.AddDays(i++);
e.SomeContent = criteria;
});
SUT.AddMany<T, TKey>(documents);
var expectedMin = documents.OrderBy(e => e.Nested.SomeDate).First();
// Act
var result = SUT.GetMinValue< T, TKey, DateTime >(e => e.SomeContent == criteria, e => e.Nested.SomeDate, PartitionKey);
// Assert
Assert.True(result != default(DateTime));
Assert.Equal(expectedMin.Nested.SomeDate.Date, result.Date);
}
[Fact]
public async Task GetMinValueAsync()
{
// Arrange
var criteria = $"{GetTestName()}.{DocumentTypeName}.{Guid.NewGuid()}";
var documents = CreateTestDocuments(5);
var i = 1;
documents.ForEach(e => {
e.Nested.SomeDate = e.Nested.SomeDate.AddDays(i++);
e.SomeContent = criteria;
});
SUT.AddMany<T, TKey>(documents);
var expectedMin = documents.OrderBy(e => e.Nested.SomeDate).First();
// Act
var result = await SUT.GetMinValueAsync< T, TKey, DateTime >(e => e.SomeContent == criteria, e => e.Nested.SomeDate, PartitionKey);
// Assert
Assert.True(result != default(DateTime));
Assert.Equal(expectedMin.Nested.SomeDate.Date, result.Date);
}
#endregion Max / Min Queries
#region Index Management
static SemaphoreSlim textIndexSemaphore = new SemaphoreSlim(1, 1);
[Fact]
public async Task CreateTextIndexNoOptionAsync()
{
// Arrange
const string expectedIndexName = "SomeContent_text";
// Act
await textIndexSemaphore.WaitAsync();
try
{
var result = await SUT.CreateTextIndexAsync<T, TKey>(x => x.SomeContent, null, PartitionKey);
// Assert
var listOfIndexNames = await SUT.GetIndexesNamesAsync<T, TKey>(PartitionKey);
Assert.Contains(expectedIndexName, listOfIndexNames);
// Cleanup
await SUT.DropIndexAsync<T, TKey>(expectedIndexName, PartitionKey);
}
finally
{
textIndexSemaphore.Release();
}
}
[Fact]
public async Task CreateTextIndexWithOptionAsync()
{
// Arrange
string expectedIndexName = $"{Guid.NewGuid()}";
var option = new IndexCreationOptions
{
Name = expectedIndexName
};
await textIndexSemaphore.WaitAsync();
try
{
// Act
var result = await SUT.CreateTextIndexAsync<T, TKey>(x => x.Version, option, PartitionKey);
// Assert
var listOfIndexNames = await SUT.GetIndexesNamesAsync<T, TKey>(PartitionKey);
Assert.Contains(expectedIndexName, listOfIndexNames);
// Cleanup
await SUT.DropIndexAsync<T, TKey>(expectedIndexName, PartitionKey);
}
finally
{
textIndexSemaphore.Release();
}
}
[Fact]
public async Task CreateAscendingIndexAsync()
{
// Arrange
const string expectedIndexName = "SomeContent_1";
// Act
var result = await SUT.CreateAscendingIndexAsync<T, TKey>(x => x.SomeContent, null, PartitionKey);
// Assert
var listOfIndexNames = await SUT.GetIndexesNamesAsync<T, TKey>(PartitionKey);
Assert.Contains(expectedIndexName, listOfIndexNames);
// Cleanup
await SUT.DropIndexAsync<T, TKey>(expectedIndexName, PartitionKey);
}
[Fact]
public async Task CreateDescendingIndexAsync()
{
// Arrange
const string expectedIndexName = "SomeContent_-1";
// Act
var result = await SUT.CreateDescendingIndexAsync<T, TKey>(x => x.SomeContent, null, PartitionKey);
// Assert
var listOfIndexNames = await SUT.GetIndexesNamesAsync<T, TKey>(PartitionKey);
Assert.Contains(expectedIndexName, listOfIndexNames);
// Cleanup
await SUT.DropIndexAsync<T, TKey>(expectedIndexName, PartitionKey);
}
[Fact]
public async Task CreateHashedIndexAsync()
{
// Arrange
const string expectedIndexName = "SomeContent_hashed";
// Act
var result = await SUT.CreateHashedIndexAsync<T, TKey>(x => x.SomeContent, null, PartitionKey);
// Assert
var listOfIndexNames = await SUT.GetIndexesNamesAsync<T, TKey>(PartitionKey);
Assert.Contains(expectedIndexName, listOfIndexNames);
// Cleanup
await SUT.DropIndexAsync<T, TKey>(expectedIndexName, PartitionKey);
}
[Fact]
public async Task CreateCombinedTextIndexAsync()
{
// Arrange
const string expectedIndexName = "SomeContent4_text_SomeContent5_text";
// Act
Expression<Func<T, object>> ex = x => x.SomeContent4;
Expression<Func<T, object>> ex2 = x => x.SomeContent5;
var result = await SUT.CreateCombinedTextIndexAsync<T, TKey>(new[] { ex, ex2 }, null, PartitionKey);
// Assert
var listOfIndexNames = await SUT.GetIndexesNamesAsync<T, TKey>(PartitionKey);
Assert.Contains(expectedIndexName, listOfIndexNames);
// Cleanup
await SUT.DropIndexAsync<T, TKey>(expectedIndexName, PartitionKey);
}
#endregion Index Management
#region Test Utils
[MethodImpl(MethodImplOptions.NoInlining)]
private string GetCurrentMethod()
@@ -1,5 +1,6 @@
using MongoDB.Bson.Serialization.Attributes;
using MongoDbGenericRepository.Models;
using MongoDbGenericRepository.Utils;
using System;
using System.Collections.Generic;
@@ -46,7 +47,11 @@ namespace CoreIntegrationTests.Infrastructure
Children = new List<Child>();
}
public int SomeValue { get; set; }
public string SomeContent { get; set; }
public string SomeContent2 { get; set; }
public string SomeContent3 { get; set; }
public int GroupingKey { get; set; }
@@ -75,6 +80,8 @@ namespace CoreIntegrationTests.Infrastructure
}
public string SomeContent { get; set; }
public string SomeContent4 { get; set; }
public string SomeContent5 { get; set; }
public Nested Nested { get; set; }
@@ -82,22 +89,7 @@ namespace CoreIntegrationTests.Infrastructure
public TId Init<TId>()
{
var idTypeName = typeof(TKey).Name;
switch (idTypeName)
{
case "Guid":
return (TId)(object)Guid.NewGuid();
case "Int16":
return (TId)(object)GlobalVariables.Random.Next(1, short.MaxValue);
case "Int32":
return (TId)(object)GlobalVariables.Random.Next(1, int.MaxValue);
case "Int64":
return (TId)(object)(GlobalVariables.Random.NextLong(1, long.MaxValue));
case "String":
return (TId)(object)Guid.NewGuid().ToString();
default:
throw new NotSupportedException($"{idTypeName} is not supported.");
}
return IdGenerator.GetId<TId>();
}
private void InitializeFields()
+19
View File
@@ -0,0 +1,19 @@
using IntegrationTests.Infrastructure;
using MongoDB.Bson;
using NUnit.Framework;
namespace IntegrationTests
{
public class ObjectIdTestDocument : TestDoc<ObjectId>
{
}
[TestFixture]
public class CRUDObjectIdTests : MongoDbTKeyDocumentTestBase<ObjectIdTestDocument, ObjectId>
{
public override string GetClassName()
{
return "CRUDObjectIdTests";
}
}
}
+2 -16
View File
@@ -1,5 +1,6 @@
using MongoDB.Bson.Serialization.Attributes;
using MongoDbGenericRepository.Models;
using MongoDbGenericRepository.Utils;
using System;
using System.Collections.Generic;
@@ -82,22 +83,7 @@ namespace IntegrationTests.Infrastructure
public TId Init<TId>()
{
var idTypeName = typeof(TKey).Name;
switch (idTypeName)
{
case "Guid":
return (TId)(object)Guid.NewGuid();
case "Int16":
return (TId)(object)GlobalVariables.Random.Next(1, short.MaxValue);
case "Int32":
return (TId)(object)GlobalVariables.Random.Next(1, int.MaxValue);
case "Int64":
return (TId)(object)(GlobalVariables.Random.NextLong(1, long.MaxValue));
case "String":
return (TId)(object)Guid.NewGuid().ToString();
default:
throw new NotSupportedException($"{idTypeName} is not supported.");
}
return IdGenerator.GetId<TId>();
}
private void InitializeFields()
@@ -1,4 +1,9 @@
using MongoDbGenericRepository;
using MongoDB.Driver;
using MongoDbGenericRepository;
using MongoDbGenericRepository.Models;
using System;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace IntegrationTests.Infrastructure
{
@@ -18,5 +23,20 @@ namespace IntegrationTests.Infrastructure
{
MongoDbContext.DropCollection<TDocument>(partitionKey);
}
/// <summary>
/// Gets the max of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <returns></returns>
public async Task<TDocument> GetByMaxAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> orderByDescending)
where TDocument : IDocument<TKey>
where TKey : System.IEquatable<TKey>
{
return await GetCollection<TDocument, TKey>().Find(Builders<TDocument>.Filter.Where(filter))
.SortByDescending(orderByDescending)
.FirstOrDefaultAsync();
}
}
}
+11 -11
View File
@@ -31,36 +31,36 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="DnsClient, Version=1.0.7.0, Culture=neutral, PublicKeyToken=4574bb5573c51424, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.3.5\lib\net45\DnsClient.dll</HintPath>
<HintPath>..\packages\MongoDbGenericRepository.1.3.8\lib\net45\DnsClient.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Bson, Version=2.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.3.5\lib\net45\MongoDB.Bson.dll</HintPath>
<Reference Include="MongoDB.Bson, Version=2.7.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.3.8\lib\net45\MongoDB.Bson.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver, Version=2.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.3.5\lib\net45\MongoDB.Driver.dll</HintPath>
<Reference Include="MongoDB.Driver, Version=2.7.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.3.8\lib\net45\MongoDB.Driver.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver.Core, Version=2.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.3.5\lib\net45\MongoDB.Driver.Core.dll</HintPath>
<Reference Include="MongoDB.Driver.Core, Version=2.7.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.3.8\lib\net45\MongoDB.Driver.Core.dll</HintPath>
</Reference>
<Reference Include="MongoDbGenericRepository, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.3.5\lib\net45\MongoDbGenericRepository.dll</HintPath>
<HintPath>..\packages\MongoDbGenericRepository.1.3.8\lib\net45\MongoDbGenericRepository.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.9.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.3.5\lib\net45\System.Buffers.dll</HintPath>
<HintPath>..\packages\MongoDbGenericRepository.1.3.8\lib\net45\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MongoDbGenericRepository.1.3.5\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
<Private>True</Private>
<HintPath>..\packages\MongoDbGenericRepository.1.3.8\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CRUDObjectIdTests.cs" />
<Compile Include="CRUDPartitionedTests.cs" />
<Compile Include="CRUDTKeyPartitionedCollectionNameAttributeTests.cs" />
<Compile Include="CRUDTests.cs" />
+4 -4
View File
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DnsClient" version="1.0.7" targetFramework="net461" />
<package id="MongoDB.Bson" version="2.5.0" targetFramework="net461" />
<package id="MongoDB.Driver" version="2.5.0" targetFramework="net461" />
<package id="MongoDB.Driver.Core" version="2.5.0" targetFramework="net461" />
<package id="MongoDbGenericRepository" version="1.3.5" targetFramework="net461" />
<package id="MongoDB.Bson" version="2.7.0" targetFramework="net461" />
<package id="MongoDB.Driver" version="2.7.0" targetFramework="net461" />
<package id="MongoDB.Driver.Core" version="2.7.0" targetFramework="net461" />
<package id="MongoDbGenericRepository" version="1.3.8" targetFramework="net461" />
<package id="NUnit" version="3.9.0" targetFramework="net461" />
<package id="NUnit.ConsoleRunner" version="3.7.0" targetFramework="net461" />
<package id="System.Buffers" version="4.3.0" targetFramework="net461" />
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Alexandre SPIESER
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -12,7 +12,7 @@ namespace MongoDbGenericRepository
/// <summary>
/// The IBaseMongoRepository exposes the CRUD functionality of the BaseMongoRepository.
/// </summary>
public interface IBaseMongoRepository : IReadOnlyMongoRepository
public interface IBaseMongoRepository : IReadOnlyMongoRepository, IMongoDbCollectionIndexRepository
{
#region Create
@@ -167,6 +167,7 @@ namespace MongoDbGenericRepository
/// <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>
bool UpdateOne<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument;
@@ -183,11 +184,11 @@ namespace MongoDbGenericRepository
/// For the entity 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<bool> UpdateOneAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument;
@@ -255,6 +256,7 @@ namespace MongoDbGenericRepository
/// <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>
bool UpdateOne<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>;
@@ -281,6 +283,7 @@ namespace MongoDbGenericRepository
/// <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<bool> UpdateOneAsync<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>;
@@ -0,0 +1,193 @@
using MongoDbGenericRepository.Models;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace MongoDbGenericRepository
{
/// <summary>
/// The repository interface for managing indexes
/// </summary>
public interface IMongoDbCollectionIndexRepository
{
/// <summary>
/// Create a text index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
where TDocument : IDocument;
/// <summary>
/// Create a text index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null) where TDocument : IDocument;
/// <summary>
/// Creates an index on the given field in ascending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateAscendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates an index on the given field in descending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>A string containing the result of the operation.</returns>
Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
where TDocument : IDocument;
/// <summary>
/// Creates an index on the given field in descending order.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>A string containing the result of the operation.</returns>
Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
where TDocument : IDocument;
/// <summary>
/// Creates a hashed index on the given field.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="field">The field we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Creates a combined text index.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="fields">The fields we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateCombinedTextIndexAsync<TDocument>(IEnumerable<Expression<Func<TDocument, object>>> fields, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
where TDocument : IDocument;
/// <summary>
/// Creates a combined text index.
/// IndexCreationOptions can be supplied to further specify
/// how the creation should be done.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <typeparam name="TKey">The type of the primary key for a Document.</typeparam>
/// <param name="fields">The fields we want to index.</param>
/// <param name="indexCreationOptions">Options for creating an index.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>The result of the create index operation.</returns>
Task<string> CreateCombinedTextIndexAsync<TDocument, TKey>(IEnumerable<Expression<Func<TDocument, object>>> fields, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Drops the index given a field name
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="indexName">The name of the index</param>
/// <param name="partitionKey">An optional partition key</param>
Task DropIndexAsync<TDocument>(string indexName, string partitionKey = null)
where TDocument : IDocument;
/// <summary>
/// Drops the index given a field name
/// </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="indexName">The name of the index</param>
/// <param name="partitionKey">An optional partition key</param>
Task DropIndexAsync<TDocument, TKey>(string indexName, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Returns the names of the indexes present on a collection.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="partitionKey">An optional partition key</param>
/// <returns>A list containing the names of the indexes on on the concerned collection.</returns>
Task<List<string>> GetIndexesNamesAsync<TDocument>(string partitionKey = null)
where TDocument : IDocument;
/// <summary>
/// Returns the names of the indexes present on a collection.
/// </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="partitionKey">An optional partition key</param>
/// <returns>A list containing the names of the indexes on on the concerned collection.</returns>
Task<List<string>> GetIndexesNamesAsync<TDocument, TKey>(string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
}
}
@@ -24,29 +24,13 @@ namespace MongoDbGenericRepository
/// </summary>
/// <typeparam name="TDocument"></typeparam>
/// <param name="partitionKey">The value of the partition key.</param>
IMongoCollection<TDocument> GetCollection<TDocument>(string partitionKey = null) where TDocument : IDocument;
/// <summary>
/// Returns a collection for a document type that has a partition key.
/// </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="partitionKey">The value of the partition key.</param>
IMongoCollection<TDocument> GetCollection<TDocument, TKey>(string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Drops a collection, use very carefully.
/// </summary>
/// <typeparam name="TDocument"></typeparam>
void DropCollection<TDocument>();
IMongoCollection<TDocument> GetCollection<TDocument>(string partitionKey = null);
/// <summary>
/// Drops a collection having a partitionkey, use very carefully.
/// </summary>
/// <typeparam name="TDocument"></typeparam>
void DropCollection<TDocument>(string partitionKey);
void DropCollection<TDocument>(string partitionKey = null);
/// <summary>
/// Sets the Guid representation of the MongoDb Driver.
@@ -159,7 +159,6 @@ namespace MongoDbGenericRepository
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Returns a collection cursor.
/// </summary>
@@ -239,6 +238,193 @@ namespace MongoDbGenericRepository
where TKey : IEquatable<TKey>;
#endregion
#region Min / Max
/// <summary>
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="orderByDescending">A property selector to order by descending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
Task<TDocument> GetByMaxAsync<TDocument>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> orderByDescending, string partitionKey = null)
where TDocument : IDocument;
/// <summary>
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="orderByDescending">A property selector to order by descending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
/// <returns></returns>
TDocument GetByMax<TDocument>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> orderByDescending, string partitionKey = null)
where TDocument : IDocument;
/// <summary>
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="orderByAscending">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
Task<TDocument> GetByMinAsync<TDocument>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> orderByAscending, string partitionKey = null)
where TDocument : IDocument;
/// <summary>
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="orderByAscending">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
TDocument GetByMin<TDocument>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> orderByAscending, string partitionKey = null)
where TDocument : IDocument;
/// <summary>
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="orderByAscending">A property selector to order by descending.</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)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="orderByAscending">A property selector to order by descending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
TDocument GetByMax<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> orderByDescending, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="orderByAscending">A property selector to order by ascending.</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)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="orderByAscending">A property selector to order by ascending.</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)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</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="maxValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
Task<TValue> GetMaxValueAsync<TDocument, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> maxValueSelector, string partitionKey = null)
where TDocument : IDocument;
/// <summary>
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="orderByAscending">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
Task<TValue> GetMaxValueAsync<TDocument, TKey, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> maxValueSelector, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</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="maxValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
TValue GetMaxValue<TDocument, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> maxValueSelector, string partitionKey = null)
where TDocument : IDocument;
/// <summary>
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="orderByAscending">A property selector to order by ascending.</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)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</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="minValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partition key.</param>
Task<TValue> GetMinValueAsync<TDocument, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> minValueSelector, string partitionKey = null)
where TDocument : IDocument;
/// <summary>
/// Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</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>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="minValueSelector">A property selector to order by ascending.</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)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
/// <summary>
/// Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</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="minValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partition key.</param>
TValue GetMinValue<TDocument, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> minValueSelector, string partitionKey = null)
where TDocument : IDocument;
/// <summary>
/// Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</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>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="minValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partition key.</param>
TValue GetMinValue<TDocument, TKey, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> minValueSelector, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>;
#endregion
}
}
@@ -17,6 +17,10 @@ namespace MongoDbGenericRepository.Attributes
/// </summary>
public string Name { get; set; }
/// <summary>
/// The constructor.
/// </summary>
/// <param name="name">The name of the collection.</param>
public CollectionNameAttribute(string name)
{
this.Name = name;
@@ -0,0 +1,176 @@
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq.Expressions;
using MongoDbGenericRepository.Models;
using System.Linq;
namespace MongoDbGenericRepository
{
/// <summary>
/// The base Repository, it is meant to be inherited from by your custom custom MongoRepository implementation.
/// Its constructor must be given a connection string and a database name.
/// </summary>
public abstract partial class BaseMongoRepository : ReadOnlyMongoRepository, IBaseMongoRepository
{
#region Index Management
/// <inheritdoc />
public async Task<string> CreateTextIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
where TDocument : IDocument
{
return await CreateTextIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey);
}
/// <inheritdoc />
public async Task<string> CreateTextIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await HandlePartitioned<TDocument, TKey>(partitionKey).Indexes
.CreateOneAsync(
new CreateIndexModel<TDocument>(
Builders<TDocument>.IndexKeys.Text(field),
indexCreationOptions == null ? null : MapIndexOptions(indexCreationOptions)
));
}
/// <inheritdoc />
public async Task<string> CreateAscendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null) where TDocument : IDocument
{
return await CreateAscendingIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey);
}
/// <inheritdoc />
public async Task<string> CreateAscendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
var collection = HandlePartitioned<TDocument, TKey>(partitionKey);
var createOptions = indexCreationOptions == null ? null : MapIndexOptions(indexCreationOptions);
var indexKey = Builders<TDocument>.IndexKeys;
return await collection.Indexes
.CreateOneAsync(
new CreateIndexModel<TDocument>(indexKey.Ascending(field), createOptions));
}
/// <inheritdoc />
public async Task<string> CreateDescendingIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
where TDocument : IDocument
{
return await CreateDescendingIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey);
}
/// <inheritdoc />
public async Task<string> CreateDescendingIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
var collection = HandlePartitioned<TDocument, TKey>(partitionKey);
var createOptions = indexCreationOptions == null ? null : MapIndexOptions(indexCreationOptions);
var indexKey = Builders<TDocument>.IndexKeys;
return await collection.Indexes
.CreateOneAsync(
new CreateIndexModel<TDocument>(indexKey.Descending(field), createOptions));
}
/// <inheritdoc />
public async Task<string> CreateHashedIndexAsync<TDocument>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
where TDocument : IDocument
{
return await CreateHashedIndexAsync<TDocument, Guid>(field, indexCreationOptions, partitionKey);
}
/// <inheritdoc />
public async Task<string> CreateHashedIndexAsync<TDocument, TKey>(Expression<Func<TDocument, object>> field, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
var collection = HandlePartitioned<TDocument, TKey>(partitionKey);
var createOptions = indexCreationOptions == null ? null : MapIndexOptions(indexCreationOptions);
var indexKey = Builders<TDocument>.IndexKeys;
return await collection.Indexes
.CreateOneAsync(
new CreateIndexModel<TDocument>(indexKey.Hashed(field), createOptions));
}
/// <inheritdoc />
public async Task<string> CreateCombinedTextIndexAsync<TDocument>(IEnumerable<Expression<Func<TDocument, object>>> fields, IndexCreationOptions indexCreationOptions = null, string partitionKey = null) where TDocument : IDocument
{
return await CreateCombinedTextIndexAsync<TDocument, Guid>(fields, indexCreationOptions, partitionKey);
}
/// <inheritdoc />
public async Task<string> CreateCombinedTextIndexAsync<TDocument, TKey>(IEnumerable<Expression<Func<TDocument, object>>> fields, IndexCreationOptions indexCreationOptions = null, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
var collection = HandlePartitioned<TDocument, TKey>(partitionKey);
var createOptions = indexCreationOptions == null ? null : MapIndexOptions(indexCreationOptions);
var listOfDefs = new List<IndexKeysDefinition<TDocument>>();
foreach (var field in fields)
{
listOfDefs.Add(Builders<TDocument>.IndexKeys.Text(field));
}
return await collection.Indexes
.CreateOneAsync(new CreateIndexModel<TDocument>(Builders<TDocument>.IndexKeys.Combine(listOfDefs), createOptions));
}
/// <inheritdoc />
public async Task DropIndexAsync<TDocument>(string indexName, string partitionKey = null)
where TDocument : IDocument
{
await DropIndexAsync<TDocument, Guid>(indexName, partitionKey);
}
/// <inheritdoc />
public async Task DropIndexAsync<TDocument, TKey>(string indexName, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
await HandlePartitioned<TDocument, TKey>(partitionKey).Indexes.DropOneAsync(indexName);
}
/// <inheritdoc />
public async Task<List<string>> GetIndexesNamesAsync<TDocument>(string partitionKey = null)
where TDocument : IDocument
{
return await GetIndexesNamesAsync<TDocument, Guid>(partitionKey);
}
/// <inheritdoc />
public async Task<List<string>> GetIndexesNamesAsync<TDocument, TKey>(string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
var indexCursor = await HandlePartitioned<TDocument, TKey>(partitionKey).Indexes.ListAsync();
var indexes = await indexCursor.ToListAsync();
return indexes.Select(e => e["name"].ToString()).ToList();
}
#endregion Index Management
private CreateIndexOptions MapIndexOptions(IndexCreationOptions indexCreationOptions)
{
return new CreateIndexOptions
{
Unique = indexCreationOptions.Unique,
TextIndexVersion = indexCreationOptions.TextIndexVersion,
SphereIndexVersion = indexCreationOptions.SphereIndexVersion,
Sparse = indexCreationOptions.Sparse,
Name = indexCreationOptions.Name,
Min = indexCreationOptions.Min,
Max = indexCreationOptions.Max,
LanguageOverride = indexCreationOptions.LanguageOverride,
ExpireAfter = indexCreationOptions.ExpireAfter,
DefaultLanguage = indexCreationOptions.DefaultLanguage,
BucketSize = indexCreationOptions.BucketSize,
Bits = indexCreationOptions.Bits,
Background = indexCreationOptions.Background,
Version = indexCreationOptions.Version
};
}
}
}
@@ -13,10 +13,8 @@ namespace MongoDbGenericRepository
/// The base Repository, it is meant to be inherited from by your custom custom MongoRepository implementation.
/// Its constructor must be given a connection string and a database name.
/// </summary>
public abstract class BaseMongoRepository : ReadOnlyMongoRepository, IBaseMongoRepository
public abstract partial class BaseMongoRepository : ReadOnlyMongoRepository, IBaseMongoRepository
{
private static readonly Random Random = new Random();
/// <summary>
/// The constructor taking a connection string and a database name.
/// </summary>
@@ -83,11 +81,22 @@ namespace MongoDbGenericRepository
{
return;
}
foreach (var doc in documents)
foreach (var document in documents)
{
FormatDocument(doc);
FormatDocument(document);
}
// cannot use typeof(IPartitionedDocument).IsAssignableFrom(typeof(TDocument)), not available in netstandard 1.5
if (documents.Any(e => e is IPartitionedDocument))
{
foreach (var group in documents.GroupBy(e => ((IPartitionedDocument)e).PartitionKey))
{
await HandlePartitioned(group.FirstOrDefault()).InsertManyAsync(group.ToList());
}
}
else
{
await GetCollection<TDocument>().InsertManyAsync(documents.ToList());
}
await HandlePartitioned(documents.FirstOrDefault()).InsertManyAsync(documents);
}
/// <summary>
@@ -106,7 +115,18 @@ namespace MongoDbGenericRepository
{
FormatDocument(document);
}
HandlePartitioned(documents.FirstOrDefault()).InsertMany(documents.ToList());
// cannot use typeof(IPartitionedDocument).IsAssignableFrom(typeof(TDocument)), not available in netstandard 1.5
if (documents.Any(e => e is IPartitionedDocument))
{
foreach (var group in documents.GroupBy(e => ((IPartitionedDocument)e).PartitionKey))
{
HandlePartitioned(group.FirstOrDefault()).InsertMany(group.ToList());
}
}
else
{
GetCollection<TDocument>().InsertMany(documents.ToList());
}
}
#endregion Create
@@ -158,11 +178,22 @@ namespace MongoDbGenericRepository
{
return;
}
foreach (var doc in documents)
foreach (var document in documents)
{
FormatDocument<TDocument, TKey>(doc);
FormatDocument<TDocument, TKey>(document);
}
// cannot use typeof(IPartitionedDocument).IsAssignableFrom(typeof(TDocument)), not available in netstandard 1.5
if (documents.Any(e => e is IPartitionedDocument))
{
foreach (var group in documents.GroupBy(e => ((IPartitionedDocument)e).PartitionKey))
{
await HandlePartitioned<TDocument, TKey>(group.FirstOrDefault()).InsertManyAsync(group.ToList());
}
}
else
{
await GetCollection<TDocument, TKey>().InsertManyAsync(documents.ToList());
}
await HandlePartitioned<TDocument, TKey>(documents.FirstOrDefault()).InsertManyAsync(documents);
}
/// <summary>
@@ -184,9 +215,19 @@ namespace MongoDbGenericRepository
{
FormatDocument<TDocument, TKey>(document);
}
HandlePartitioned<TDocument, TKey>(documents.FirstOrDefault()).InsertMany(documents.ToList());
// cannot use typeof(IPartitionedDocument).IsAssignableFrom(typeof(TDocument)), not available in netstandard 1.5
if (documents.Any(e => e is IPartitionedDocument))
{
foreach (var group in documents.GroupBy(e => ((IPartitionedDocument)e).PartitionKey))
{
HandlePartitioned<TDocument, TKey>(group.FirstOrDefault()).InsertMany(group.ToList());
}
}
else
{
GetCollection<TDocument, TKey>().InsertMany(documents.ToList());
}
}
#endregion
@@ -285,6 +326,7 @@ namespace MongoDbGenericRepository
/// <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 bool UpdateOne<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument
{
@@ -314,11 +356,11 @@ namespace MongoDbGenericRepository
/// For the entity 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<bool> UpdateOneAsync<TDocument, TField>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TField>> field, TField value, string partitionKey = null)
where TDocument : IDocument
{
@@ -471,13 +513,12 @@ namespace MongoDbGenericRepository
/// <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<bool> UpdateOneAsync<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>
{
var collection = string.IsNullOrEmpty(partitionKey) ? GetCollection<TDocument, TKey>() : GetCollection<TDocument, TKey>(partitionKey);
var updateRes = await collection.UpdateOneAsync(Builders<TDocument>.Filter.Where(filter), Builders<TDocument>.Update.Set(field, value));
return updateRes.ModifiedCount == 1;
return await UpdateOneAsync<TDocument, TKey, TField>(Builders<TDocument>.Filter.Where(filter), field, value, partitionKey);
}
/// <summary>
@@ -508,13 +549,12 @@ namespace MongoDbGenericRepository
/// <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 bool UpdateOne<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>
{
var collection = string.IsNullOrEmpty(partitionKey) ? GetCollection<TDocument, TKey>() : GetCollection<TDocument, TKey>(partitionKey);
var updateRes = collection.UpdateOne(Builders<TDocument>.Filter.Where(filter), Builders<TDocument>.Update.Set(field, value));
return updateRes.ModifiedCount == 1;
return UpdateOne<TDocument, TKey, TField>(Builders<TDocument>.Filter.Where(filter), field, value, partitionKey);
}
#endregion Update
@@ -529,7 +569,7 @@ namespace MongoDbGenericRepository
/// <returns>The number of documents deleted.</returns>
public virtual async Task<long> DeleteOneAsync<TDocument>(TDocument document) where TDocument : IDocument
{
return (await HandlePartitioned(document).DeleteOneAsync(x => x.Id == document.Id)).DeletedCount;
return await DeleteOneAsync<TDocument, Guid>(document);
}
/// <summary>
@@ -540,7 +580,7 @@ namespace MongoDbGenericRepository
/// <returns>The number of documents deleted.</returns>
public virtual long DeleteOne<TDocument>(TDocument document) where TDocument : IDocument
{
return HandlePartitioned(document).DeleteOne(x => x.Id == document.Id).DeletedCount;
return DeleteOne<TDocument, Guid>(document);
}
/// <summary>
@@ -552,7 +592,7 @@ namespace MongoDbGenericRepository
/// <returns>The number of documents deleted.</returns>
public virtual long DeleteOne<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
{
return HandlePartitioned<TDocument>(partitionKey).DeleteOne(filter).DeletedCount;
return DeleteOne<TDocument, Guid>(filter, partitionKey);
}
/// <summary>
@@ -564,7 +604,7 @@ namespace MongoDbGenericRepository
/// <returns>The number of documents deleted.</returns>
public virtual async Task<long> DeleteOneAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
{
return (await HandlePartitioned<TDocument>(partitionKey).DeleteOneAsync(filter)).DeletedCount;
return await DeleteOneAsync<TDocument, Guid>(filter, partitionKey);
}
/// <summary>
@@ -587,12 +627,7 @@ namespace MongoDbGenericRepository
/// <returns>The number of documents deleted.</returns>
public virtual async Task<long> DeleteManyAsync<TDocument>(IEnumerable<TDocument> documents) where TDocument : IDocument
{
if (!documents.Any())
{
return 0;
}
var idsTodelete = documents.Select(e => e.Id).ToArray();
return (await HandlePartitioned(documents.FirstOrDefault()).DeleteManyAsync(x => idsTodelete.Contains(x.Id))).DeletedCount;
return await DeleteManyAsync<TDocument, Guid>(documents);
}
/// <summary>
@@ -603,12 +638,7 @@ namespace MongoDbGenericRepository
/// <returns>The number of documents deleted.</returns>
public virtual long DeleteMany<TDocument>(IEnumerable<TDocument> documents) where TDocument : IDocument
{
if (!documents.Any())
{
return 0;
}
var idsTodelete = documents.Select(e => e.Id).ToArray();
return HandlePartitioned(documents.FirstOrDefault()).DeleteMany(x => idsTodelete.Contains(x.Id)).DeletedCount;
return DeleteMany<TDocument, Guid>(documents);
}
/// <summary>
@@ -717,9 +747,23 @@ namespace MongoDbGenericRepository
{
return 0;
}
// cannot use typeof(IPartitionedDocument).IsAssignableFrom(typeof(TDocument)), not available in netstandard 1.5
if (documents.Any(e => e is IPartitionedDocument))
{
long deleteCount = 0;
foreach (var group in documents.GroupBy(e => ((IPartitionedDocument)e).PartitionKey))
{
var groupIdsTodelete = group.Select(e => e.Id).ToArray();
deleteCount += (await HandlePartitioned<TDocument, TKey>(group.FirstOrDefault()).DeleteManyAsync(x => groupIdsTodelete.Contains(x.Id))).DeletedCount;
}
return deleteCount;
}
else
{
var idsTodelete = documents.Select(e => e.Id).ToArray();
return (await HandlePartitioned<TDocument, TKey>(documents.FirstOrDefault()).DeleteManyAsync(x => idsTodelete.Contains(x.Id))).DeletedCount;
}
}
/// <summary>
/// Deletes a list of documents.
@@ -736,8 +780,22 @@ namespace MongoDbGenericRepository
{
return 0;
}
// cannot use typeof(IPartitionedDocument).IsAssignableFrom(typeof(TDocument)), not available in netstandard 1.5
if (documents.Any(e => e is IPartitionedDocument))
{
long deleteCount = 0;
foreach (var group in documents.GroupBy(e => ((IPartitionedDocument)e).PartitionKey))
{
var groupIdsTodelete = group.Select(e => e.Id).ToArray();
deleteCount += (HandlePartitioned<TDocument, TKey>(group.FirstOrDefault()).DeleteMany(x => groupIdsTodelete.Contains(x.Id))).DeletedCount;
}
return deleteCount;
}
else
{
var idsTodelete = documents.Select(e => e.Id).ToArray();
return HandlePartitioned<TDocument, TKey>(documents.FirstOrDefault()).DeleteMany(x => idsTodelete.Contains(x.Id)).DeletedCount;
return (HandlePartitioned<TDocument, TKey>(documents.FirstOrDefault()).DeleteMany(x => idsTodelete.Contains(x.Id))).DeletedCount;
}
}
/// <summary>
@@ -1022,26 +1080,6 @@ namespace MongoDbGenericRepository
#endregion Find And Update
private TKey SetIdField<TKey>()
{
var idTypeName = typeof(TKey).Name;
switch (idTypeName)
{
case "Guid":
return (TKey)(object)Guid.NewGuid();
case "Int16":
return (TKey)(object)Random.Next(1, short.MaxValue);
case "Int32":
return (TKey)(object)Random.Next(1, int.MaxValue);
case "Int64":
return (TKey)(object)(Random.NextLong(1, long.MaxValue));
case "String":
return (TKey)(object)Guid.NewGuid().ToString();
}
throw new ArgumentException($"{idTypeName} is not a supported Id type, the Id of the document cannot be set.");
}
/// <summary>
/// Sets the value of the document Id if it is not set already.
/// </summary>
@@ -1061,7 +1099,7 @@ namespace MongoDbGenericRepository
|| (defaultTKey != null
&& defaultTKey.Equals(document.Id)))
{
document.Id = SetIdField<TKey>();
document.Id = IdGenerator.GetId<TKey>();
}
}
@@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MongoDbGenericRepository.Models
{
/// <summary>
/// Options for creating an index.
/// </summary>
public class IndexCreationOptions
{
/// <summary>
/// Gets or sets a value indicating whether the index is a unique index.
/// </summary>
public bool? Unique { get; set; }
/// <summary>
/// Gets or sets the index version for text indexes.
/// </summary>
public int? TextIndexVersion { get; set; }
/// <summary>
/// Gets or sets the index version for 2dsphere indexes.
/// </summary>
public int? SphereIndexVersion { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the index is a sparse index.
/// </summary>
public bool? Sparse { get; set; }
/// <summary>
/// Gets or sets the index name.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Gets or sets the min value for 2d indexes.
/// </summary>
public double? Min { get; set; }
/// <summary>
/// Gets or sets the max value for 2d indexes.
/// </summary>
public double? Max { get; set; }
/// <summary>
/// Gets or sets the language override.
/// </summary>
public string LanguageOverride { get; set; }
/// <summary>
/// Gets or sets when documents expire (used with TTL indexes).
/// </summary>
public TimeSpan? ExpireAfter { get; set; }
/// <summary>
/// Gets or sets the default language.
/// </summary>
public string DefaultLanguage { get; set; }
/// <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.
/// </summary>
public int? Bits { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to create the index in the background.
/// </summary>
public bool? Background { get; set; }
/// <summary>
/// Gets or sets the version of the index.
/// </summary>
public int? Version { get; set; }
}
}
+31 -40
View File
@@ -1,8 +1,6 @@
using MongoDB.Driver;
using MongoDbGenericRepository.Attributes;
using MongoDbGenericRepository.Models;
using MongoDbGenericRepository.Utils;
using System;
using System.Linq;
using System.Reflection;
@@ -23,27 +21,33 @@ namespace MongoDbGenericRepository
/// </summary>
public IMongoDatabase Database { get; }
static MongoDbContext()
{
// Avoid legacy UUID representation: use Binary 0x04 subtype.
MongoDefaults.GuidRepresentation = MongoDB.Bson.GuidRepresentation.Standard;
}
/// <summary>
/// Sets the Guid representation of the MongoDb Driver.
/// </summary>
/// <param name="guidRepresentation">The new value of the GuidRepresentation</param>
public void SetGuidRepresentation(MongoDB.Bson.GuidRepresentation guidRepresentation)
public virtual void SetGuidRepresentation(MongoDB.Bson.GuidRepresentation guidRepresentation)
{
MongoDefaults.GuidRepresentation = guidRepresentation;
}
/// <summary>
/// Initialize the Guid representation of the MongoDb Driver.
/// Override this method to change the default GuidRepresentation.
/// </summary>
protected virtual void InitializeGuidRepresentation()
{
// by default, avoid lefacy UUID representation: use Binary 0x04 subtype.
MongoDefaults.GuidRepresentation = MongoDB.Bson.GuidRepresentation.Standard;
}
/// <summary>
/// The constructor of the MongoDbContext, it needs a an object implementing <see cref="IMongoDatabase"/>.
/// </summary>
/// <param name="mongoDatabase">An object implementing IMongoDatabase</param>
public MongoDbContext(IMongoDatabase mongoDatabase)
{
// Avoid legacy UUID representation: use Binary 0x04 subtype.
InitializeGuidRepresentation();
Database = mongoDatabase;
Client = Database.Client;
}
@@ -55,6 +59,7 @@ namespace MongoDbGenericRepository
/// <param name="databaseName">The name of your database.</param>
public MongoDbContext(string connectionString, string databaseName)
{
InitializeGuidRepresentation();
Client = new MongoClient(connectionString);
Database = Client.GetDatabase(databaseName);
}
@@ -72,59 +77,45 @@ namespace MongoDbGenericRepository
}
/// <summary>
/// Returns a collection for a document type that has a partition key.
/// Returns a collection for a document type. Also handles document types with a partition key.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <param name="partitionKey">The value of the partition key.</param>
public IMongoCollection<TDocument> GetCollection<TDocument>(string partitionKey = null) where TDocument : IDocument
/// <param name="partitionKey">The optional value of the partition key.</param>
public IMongoCollection<TDocument> GetCollection<TDocument>(string partitionKey = null)
{
if (string.IsNullOrEmpty(partitionKey))
{
return Database.GetCollection<TDocument>(GetAttributeCollectionName<TDocument>() ?? Pluralize<TDocument>());
}
return Database.GetCollection<TDocument>(partitionKey + "-" + GetAttributeCollectionName<TDocument>() ?? Pluralize<TDocument>());
}
/// <summary>
/// Returns a collection for a document type that has a partition key.
/// </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="partitionKey">The value of the partition key.</param>
public IMongoCollection<TDocument> GetCollection<TDocument, TKey>(string partitionKey)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
if (string.IsNullOrEmpty(partitionKey))
{
return Database.GetCollection<TDocument>(GetAttributeCollectionName<TDocument>() ?? Pluralize<TDocument>());
}
return Database.GetCollection<TDocument>(partitionKey + "-" + GetAttributeCollectionName<TDocument>() ?? Pluralize<TDocument>());
return Database.GetCollection<TDocument>(GetCollectionName<TDocument>(partitionKey));
}
/// <summary>
/// Drops a collection, use very carefully.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
public void DropCollection<TDocument>()
public void DropCollection<TDocument>(string partitionKey = null)
{
Database.DropCollection(GetAttributeCollectionName<TDocument>() ?? Pluralize<TDocument>());
Database.DropCollection(GetCollectionName<TDocument>(partitionKey));
}
/// <summary>
/// Drops a collection having a partitionkey, use very carefully.
/// Given the docmuent type and the partition key, returns the name of the collection it belongs to.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
public void DropCollection<TDocument>(string partitionKey)
/// <param name="partitionKey">The value of the partition key.</param>
/// <returns>The name of the collection.</returns>
private string GetCollectionName<TDocument>(string partitionKey)
{
Database.DropCollection(partitionKey + "-" + GetAttributeCollectionName<TDocument>() ?? Pluralize<TDocument>());
var collectionName = GetAttributeCollectionName<TDocument>() ?? Pluralize<TDocument>();
if (string.IsNullOrEmpty(partitionKey))
{
return collectionName;
}
return $"{partitionKey}-{collectionName}";
}
/// <summary>
/// Very naively pluralizes a TDocument type name.
/// </summary>
/// <typeparam name="TDocument">The type representing a Document.</typeparam>
/// <returns></returns>
/// <returns>The pluralized document name.</returns>
private string Pluralize<TDocument>()
{
return (typeof(TDocument).Name.Pluralize()).Camelize();
@@ -17,7 +17,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.5.0" />
<PackageReference Include="MongoDB.Driver" Version="2.7.0" />
</ItemGroup>
</Project>
@@ -2,7 +2,7 @@
<package >
<metadata>
<id>MongoDbGenericRepository</id>
<version>1.3.5</version>
<version>1.3.8</version>
<title>MongoDb Generic Repository</title>
<authors>Alexandre Spieser</authors>
<owners>Alexandre Spieser</owners>
@@ -10,11 +10,11 @@
<projectUrl>https://github.com/alexandre-spieser/mongodb-generic-repository</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A generic repository implementation using the MongoDB C# Sharp 2.0 driver.</description>
<releaseNotes>Adding CollectionName attribute to specify alternate collection name (thanks Etchelon).</releaseNotes>
<copyright>Copyright 2017 (c) Alexandre Spieser. All rights reserved.</copyright>
<releaseNotes>Release notes are at https://github.com/alexandre-spieser/mongodb-generic-repository/releases</releaseNotes>
<copyright>Copyright 2018 (c) Alexandre Spieser. All rights reserved.</copyright>
<tags>MongoDb Repository Generic NoSql</tags>
<dependencies>
<dependency id="MongoDB.Driver" version="2.5.0" />
<dependency id="MongoDB.Driver" version="2.7.0" />
</dependencies>
</metadata>
<files>
@@ -123,7 +123,7 @@ namespace MongoDbGenericRepository
/// <param name="partitionKey">An optional partition key.</param>
public async Task<bool> AnyAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
{
var count = await HandlePartitioned<TDocument>(partitionKey).CountAsync(filter);
var count = await HandlePartitioned<TDocument>(partitionKey).CountDocumentsAsync(filter);
return (count > 0);
}
@@ -135,7 +135,7 @@ namespace MongoDbGenericRepository
/// <param name="partitionKey">An optional partition key.</param>
public bool Any<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
{
var count = HandlePartitioned<TDocument>(partitionKey).Count(filter);
var count = HandlePartitioned<TDocument>(partitionKey).CountDocuments(filter);
return (count > 0);
}
@@ -169,7 +169,7 @@ namespace MongoDbGenericRepository
/// <param name="partitionKey">An optional partitionKey</param>
public async Task<long> CountAsync<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
{
return await HandlePartitioned<TDocument>(partitionKey).CountAsync(filter);
return await HandlePartitioned<TDocument>(partitionKey).CountDocumentsAsync(filter);
}
/// <summary>
@@ -180,7 +180,60 @@ namespace MongoDbGenericRepository
/// <param name="partitionKey">An optional partitionKey</param>
public long Count<TDocument>(Expression<Func<TDocument, bool>> filter, string partitionKey = null) where TDocument : IDocument
{
return HandlePartitioned<TDocument>(partitionKey).Find(filter).Count();
return HandlePartitioned<TDocument>(partitionKey).Find(filter).CountDocuments();
}
/// <summary>
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="maxValueSelector">A property selector to order by descending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
public async Task<TDocument> GetByMaxAsync<TDocument>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> maxValueSelector, string partitionKey = null)
where TDocument : IDocument
{
return await GetByMaxAsync<TDocument, Guid>(filter, maxValueSelector, partitionKey);
}
/// <summary>
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="maxValueSelector">A property selector to order by descending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
/// <returns></returns>
public TDocument GetByMax<TDocument>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> maxValueSelector, string partitionKey = null)
where TDocument : IDocument
{
return GetByMax<TDocument, Guid>(filter, maxValueSelector, partitionKey);
}
/// <summary>
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="minValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
public async Task<TDocument> GetByMinAsync<TDocument>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> minValueSelector, string partitionKey = null)
where TDocument : IDocument
{
return await GetByMinAsync<TDocument, Guid>(filter, minValueSelector, partitionKey);
}
/// <summary>
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="orderByAscending">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
public TDocument GetByMin<TDocument>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> orderByAscending, string partitionKey = null)
where TDocument : IDocument
{
return GetByMin<TDocument, Guid>(filter, orderByAscending, partitionKey);
}
#endregion
@@ -270,7 +323,7 @@ namespace MongoDbGenericRepository
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
var count = await HandlePartitioned<TDocument, TKey>(partitionKey).CountAsync(filter);
var count = await HandlePartitioned<TDocument, TKey>(partitionKey).CountDocumentsAsync(filter);
return (count > 0);
}
@@ -285,7 +338,7 @@ namespace MongoDbGenericRepository
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
var count = HandlePartitioned<TDocument, TKey>(partitionKey).Count(filter);
var count = HandlePartitioned<TDocument, TKey>(partitionKey).CountDocuments(filter);
return (count > 0);
}
@@ -328,7 +381,7 @@ namespace MongoDbGenericRepository
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await HandlePartitioned<TDocument, TKey>(partitionKey).CountAsync(filter);
return await HandlePartitioned<TDocument, TKey>(partitionKey).CountDocumentsAsync(filter);
}
/// <summary>
@@ -342,7 +395,239 @@ namespace MongoDbGenericRepository
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return HandlePartitioned<TDocument, TKey>(partitionKey).Find(filter).Count();
return HandlePartitioned<TDocument, TKey>(partitionKey).Find(filter).CountDocuments();
}
/// <summary>
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="maxValueSelector">A property selector to order by descending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
public async Task<TDocument> GetByMaxAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> maxValueSelector, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await GetCollection<TDocument, TKey>(partitionKey).Find(Builders<TDocument>.Filter.Where(filter))
.SortByDescending(maxValueSelector)
.Limit(1)
.FirstOrDefaultAsync();
}
/// <summary>
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="maxValueSelector">A property selector to order by descending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
public TDocument GetByMax<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> maxValueSelector, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return GetCollection<TDocument, TKey>(partitionKey).Find(Builders<TDocument>.Filter.Where(filter))
.SortByDescending(maxValueSelector)
.Limit(1)
.FirstOrDefault();
}
/// <summary>
/// Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="minValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
public async Task<TDocument> GetByMinAsync<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> minValueSelector, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await GetCollection<TDocument, TKey>(partitionKey).Find(Builders<TDocument>.Filter.Where(filter))
.SortBy(minValueSelector)
.Limit(1)
.FirstOrDefaultAsync();
}
/// <summary>
/// Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="minValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
public TDocument GetByMin<TDocument, TKey>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, object>> minValueSelector, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return GetCollection<TDocument, TKey>(partitionKey).Find(Builders<TDocument>.Filter.Where(filter))
.SortBy(minValueSelector)
.Limit(1)
.FirstOrDefault();
}
/// <summary>
/// Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</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>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="minValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partition key.</param>
private IFindFluent<TDocument, TDocument> GetMinMongoQuery<TDocument, TKey, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> minValueSelector, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return GetCollection<TDocument, TKey>(partitionKey).Find(Builders<TDocument>.Filter.Where(filter))
.SortBy(ConvertExpression(minValueSelector))
.Limit(1);
}
/// <summary>
/// Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</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>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="maxValueSelector">A property selector to order by descending.</param>
/// <param name="partitionKey">An optional partition key.</param>
private IFindFluent<TDocument, TDocument> GetMaxMongoQuery<TDocument, TKey, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> maxValueSelector, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return GetCollection<TDocument, TKey>(partitionKey).Find(Builders<TDocument>.Filter.Where(filter))
.SortByDescending(ConvertExpression(maxValueSelector))
.Limit(1);
}
/// <summary>
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</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="maxValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
public async Task<TValue> GetMaxValueAsync<TDocument, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> maxValueSelector, string partitionKey = null)
where TDocument : IDocument
{
return await GetMaxValueAsync<TDocument, Guid, TValue>(filter, maxValueSelector, partitionKey);
}
/// <summary>
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TKey">The type of the primary key.</typeparam>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="orderByAscending">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
public async Task<TValue> GetMaxValueAsync<TDocument, TKey, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> maxValueSelector, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await GetMaxMongoQuery<TDocument, TKey, TValue>(filter, maxValueSelector, partitionKey)
.Project(maxValueSelector)
.FirstOrDefaultAsync();
}
/// <summary>
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</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="maxValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
public TValue GetMaxValue<TDocument, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> maxValueSelector, string partitionKey = null)
where TDocument : IDocument
{
return GetMaxValue<TDocument, Guid, TValue>(filter, maxValueSelector, partitionKey);
}
/// <summary>
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</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>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="maxValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partitionKey.</param>
public TValue GetMaxValue<TDocument, TKey, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> maxValueSelector, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return GetMaxMongoQuery<TDocument, TKey, TValue>(filter, maxValueSelector, partitionKey)
.Project(maxValueSelector)
.FirstOrDefault();
}
/// <summary>
/// Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</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="minValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partition key.</param>
public async Task<TValue> GetMinValueAsync<TDocument, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> minValueSelector, string partitionKey = null)
where TDocument : IDocument
{
return await GetMinValueAsync<TDocument, Guid, TValue>(filter, minValueSelector, partitionKey);
}
/// <summary>
/// Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</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>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="minValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partition key.</param>
public async Task<TValue> GetMinValueAsync<TDocument, TKey, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> minValueSelector, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return await GetMinMongoQuery<TDocument, TKey, TValue>(filter, minValueSelector, partitionKey).Project(minValueSelector).FirstOrDefaultAsync();
}
/// <summary>
/// Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</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="minValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partition key.</param>
public TValue GetMinValue<TDocument, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> minValueSelector, string partitionKey = null)
where TDocument : IDocument
{
return GetMinValue<TDocument, Guid, TValue>(filter, minValueSelector, partitionKey);
}
/// <summary>
/// Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
/// </summary>
/// <typeparam name="TDocument">The document type.</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>
/// <param name="filter">A LINQ expression filter.</param>
/// <param name="minValueSelector">A property selector to order by ascending.</param>
/// <param name="partitionKey">An optional partition key.</param>
public TValue GetMinValue<TDocument, TKey, TValue>(Expression<Func<TDocument, bool>> filter, Expression<Func<TDocument, TValue>> minValueSelector, string partitionKey = null)
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return GetMinMongoQuery<TDocument, TKey, TValue>(filter, minValueSelector, partitionKey).Project(minValueSelector).FirstOrDefault();
}
#endregion
@@ -350,26 +635,16 @@ namespace MongoDbGenericRepository
#region Utility Methods
/// <summary>
/// Gets a collections for the type TDocument with the matching partition key.
/// Gets a collections for the type TDocument with the matching partition key (if any).
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <param name="partitionKey">The partion key.</param>
/// <param name="partitionKey">An optional partition key.</param>
/// <returns>An <see cref="IMongoCollection{TDocument}"/></returns>
protected IMongoCollection<TDocument> GetCollection<TDocument>(string partitionKey) where TDocument : IDocument
protected IMongoCollection<TDocument> GetCollection<TDocument>(string partitionKey = null) where TDocument : IDocument
{
return MongoDbContext.GetCollection<TDocument>(partitionKey);
}
/// <summary>
/// Gets a collections for the type TDocument
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <returns></returns>
protected IMongoCollection<TDocument> GetCollection<TDocument>() where TDocument : IDocument
{
return MongoDbContext.GetCollection<TDocument>();
}
/// <summary>
/// Gets a collections for the type TDocument
/// </summary>
@@ -429,7 +704,7 @@ namespace MongoDbGenericRepository
where TDocument : IDocument<TKey>
where TKey : IEquatable<TKey>
{
return MongoDbContext.GetCollection<TDocument, TKey>(partitionKey);
return MongoDbContext.GetCollection<TDocument>(partitionKey);
}
/// <summary>
@@ -450,6 +725,20 @@ namespace MongoDbGenericRepository
return GetCollection<TDocument, TKey>();
}
/// <summary>
/// Converts a LINQ expression of TDocument, TValue to a LINQ expression of TDocument, object
/// </summary>
/// <typeparam name="TDocument">The document type.</typeparam>
/// <typeparam name="TValue">The type of the value.</typeparam>
/// <param name="expression">The expression to convert</param>
protected static Expression<Func<TDocument, object>> ConvertExpression<TDocument, TValue>(Expression<Func<TDocument, TValue>> expression)
{
var param = expression.Parameters[0];
Expression body = expression.Body;
var convert = Expression.Convert(body, typeof(object));
return Expression.Lambda<Func<TDocument, object>>(convert, param);
}
#endregion
}
@@ -0,0 +1,39 @@
using MongoDB.Bson;
using System;
namespace MongoDbGenericRepository.Utils
{
/// <summary>
/// The IdGenerator instance, used to generate Ids of different types.
/// </summary>
public static class IdGenerator
{
private static readonly Random Random = new Random();
/// <summary>
/// Generates a random value of a given type.
/// </summary>
/// <typeparam name="TKey">The type of the value to generate.</typeparam>
/// <returns>A value of type TKey.</returns>
public static TKey GetId<TKey>()
{
var idTypeName = typeof(TKey).Name;
switch (idTypeName)
{
case "Guid":
return (TKey)(object)Guid.NewGuid();
case "Int16":
return (TKey)(object)Random.Next(1, short.MaxValue);
case "Int32":
return (TKey)(object)Random.Next(1, int.MaxValue);
case "Int64":
return (TKey)(object)(Random.NextLong(1, long.MaxValue));
case "String":
return (TKey)(object)Guid.NewGuid().ToString();
case "ObjectId":
return (TKey)(object)ObjectId.GenerateNewId();
}
throw new ArgumentException($"{idTypeName} is not a supported Id type, the Id of the document cannot be set.");
}
}
}
Binary file not shown.
@@ -141,6 +141,7 @@
<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.UpdateOneAsync``1(``0,MongoDB.Driver.UpdateDefinition{``0})">
<summary>
@@ -155,11 +156,11 @@
For the entity 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.UpdateOne``1(``0,MongoDB.Driver.UpdateDefinition{``0})">
<summary>
@@ -213,6 +214,7 @@
<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.UpdateOneAsync``3(``0,System.Linq.Expressions.Expression{System.Func{``0,``2}},``2)">
<summary>
@@ -235,6 +237,7 @@
<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.UpdateOne``3(``0,System.Linq.Expressions.Expression{System.Func{``0,``2}},``2)">
<summary>
@@ -566,6 +569,170 @@
<param name="projection">The projected group result.</param>
<param name="partitionKey">The partition key of your document, if any.</param>
</member>
<member name="T:MongoDbGenericRepository.IMongoDbCollectionIndexRepository">
<summary>
The repository interface for managing indexes
</summary>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateTextIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Create a text index on the given field.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateTextIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Create a text index on the given field.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateAscendingIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates an index on the given field in ascending order.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateAscendingIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates an index on the given field in ascending order.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateDescendingIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates an index on the given field in descending order.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>A string containing the result of the operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateDescendingIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates an index on the given field in descending order.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateHashedIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates a hashed index on the given field.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>A string containing the result of the operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateHashedIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates a hashed index on the given field.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateCombinedTextIndexAsync``1(System.Collections.Generic.IEnumerable{System.Linq.Expressions.Expression{System.Func{``0,System.Object}}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates a combined text index.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="fields">The fields we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateCombinedTextIndexAsync``2(System.Collections.Generic.IEnumerable{System.Linq.Expressions.Expression{System.Func{``0,System.Object}}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates a combined text index.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="fields">The fields we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.DropIndexAsync``1(System.String,System.String)">
<summary>
Drops the index given a field name
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="indexName">The name of the index</param>
<param name="partitionKey">An optional partition key</param>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.DropIndexAsync``2(System.String,System.String)">
<summary>
Drops the index given a field name
</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="indexName">The name of the index</param>
<param name="partitionKey">An optional partition key</param>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.GetIndexesNamesAsync``1(System.String)">
<summary>
Returns the names of the indexes present on a collection.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="partitionKey">An optional partition key</param>
<returns>A list containing the names of the indexes on on the concerned collection.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.GetIndexesNamesAsync``2(System.String)">
<summary>
Returns the names of the indexes present on a collection.
</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="partitionKey">An optional partition key</param>
<returns>A list containing the names of the indexes on on the concerned collection.</returns>
</member>
<member name="T:MongoDbGenericRepository.IMongoDbContext">
<summary>
This is the interface of the IMongoDbContext which is managed by the <see cref="T:MongoDbGenericRepository.BaseMongoRepository"/>.
@@ -588,20 +755,6 @@
<typeparam name="TDocument"></typeparam>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbContext.GetCollection``2(System.String)">
<summary>
Returns a collection for a document type that has a partition key.
</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="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbContext.DropCollection``1">
<summary>
Drops a collection, use very carefully.
</summary>
<typeparam name="TDocument"></typeparam>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbContext.DropCollection``1(System.String)">
<summary>
Drops a collection having a partitionkey, use very carefully.
@@ -816,6 +969,165 @@
<param name="filter">A LINQ expression filter.</param>
<param name="partitionKey">An optional partitionKey</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMaxAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByDescending">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMax``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByDescending">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
<returns></returns>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMinAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMin``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMaxAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMax``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMinAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMin``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMaxValueAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="maxValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMaxValueAsync``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMaxValue``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="maxValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMaxValue``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMinValueAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMinValueAsync``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMinValue``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMinValue``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="T:MongoDbGenericRepository.Attributes.CollectionNameAttribute">
<summary>
This attribute allows you to specify of the name of the collection.
@@ -830,11 +1142,21 @@
The name of the collection in which your documents are stored.
</summary>
</member>
<member name="M:MongoDbGenericRepository.Attributes.CollectionNameAttribute.#ctor(System.String)">
<summary>
The constructor.
</summary>
<param name="name">The name of the collection.</param>
</member>
<member name="T:MongoDbGenericRepository.BaseMongoRepository">
<summary>
The base Repository, it is meant to be inherited from by your custom custom MongoRepository implementation.
Its constructor must be given a connection string and a database name.
</summary>
<summary>
The base Repository, it is meant to be inherited from by your custom custom MongoRepository implementation.
Its constructor must be given a connection string and a database name.
</summary>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.#ctor(System.String,System.String)">
<summary>
@@ -985,6 +1307,7 @@
<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.UpdateOneAsync``2(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
@@ -1002,11 +1325,11 @@
For the entity 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.UpdateOne``1(``0,MongoDB.Driver.UpdateDefinition{``0})">
<summary>
@@ -1094,6 +1417,7 @@
<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.UpdateOne``3(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
@@ -1117,6 +1441,7 @@
<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.DeleteOneAsync``1(``0)">
<summary>
@@ -1428,6 +1753,48 @@
<typeparam name="TDocument">The document type.</typeparam>
<param name="document">The document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateTextIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateTextIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateAscendingIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateAscendingIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateDescendingIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateDescendingIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateHashedIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateHashedIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateCombinedTextIndexAsync``1(System.Collections.Generic.IEnumerable{System.Linq.Expressions.Expression{System.Func{``0,System.Object}}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateCombinedTextIndexAsync``2(System.Collections.Generic.IEnumerable{System.Linq.Expressions.Expression{System.Func{``0,System.Object}}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.DropIndexAsync``1(System.String,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.DropIndexAsync``2(System.String,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.GetIndexesNamesAsync``1(System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.GetIndexesNamesAsync``2(System.String)">
<inheritdoc />
</member>
<member name="T:MongoDbGenericRepository.Models.Document">
<summary>
This class represents a basic document that can be stored in MongoDb.
@@ -1477,6 +1844,81 @@
Your document must implement this class in order for the MongoDbRepository to handle them.
</summary>
</member>
<member name="T:MongoDbGenericRepository.Models.IndexCreationOptions">
<summary>
Options for creating an index.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Unique">
<summary>
Gets or sets a value indicating whether the index is a unique index.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.TextIndexVersion">
<summary>
Gets or sets the index version for text indexes.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.SphereIndexVersion">
<summary>
Gets or sets the index version for 2dsphere indexes.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Sparse">
<summary>
Gets or sets a value indicating whether the index is a sparse index.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Name">
<summary>
Gets or sets the index name.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Min">
<summary>
Gets or sets the min value for 2d indexes.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Max">
<summary>
Gets or sets the max value for 2d indexes.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.LanguageOverride">
<summary>
Gets or sets the language override.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.ExpireAfter">
<summary>
Gets or sets when documents expire (used with TTL indexes).
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.DefaultLanguage">
<summary>
Gets or sets the default language.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.BucketSize">
<summary>
Gets or sets the size of a geohash bucket.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Bits">
<summary>
Gets or sets the precision, in bits, used with geohash indexes.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Background">
<summary>
Gets or sets a value indicating whether to create the index in the background.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Version">
<summary>
Gets or sets the version of the index.
</summary>
</member>
<member name="T:MongoDbGenericRepository.Models.IPartitionedDocument">
<summary>
This class represents a document that can be inserted in a collection that can be partitioned.
@@ -1532,6 +1974,12 @@
</summary>
<param name="guidRepresentation">The new value of the GuidRepresentation</param>
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.InitializeGuidRepresentation">
<summary>
Initialize the Guid representation of the MongoDb Driver.
Override this method to change the default GuidRepresentation.
</summary>
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.#ctor(MongoDB.Driver.IMongoDatabase)">
<summary>
The constructor of the MongoDbContext, it needs a an object implementing <see cref="T:MongoDB.Driver.IMongoDatabase"/>.
@@ -1554,37 +2002,31 @@
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.GetCollection``1(System.String)">
<summary>
Returns a collection for a document type that has a partition key.
Returns a collection for a document type. Also handles document types with a partition key.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="partitionKey">The value of the partition key.</param>
<param name="partitionKey">The optional value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.GetCollection``2(System.String)">
<summary>
Returns a collection for a document type that has a partition key.
</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="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.DropCollection``1">
<member name="M:MongoDbGenericRepository.MongoDbContext.DropCollection``1(System.String)">
<summary>
Drops a collection, use very carefully.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.DropCollection``1(System.String)">
<member name="M:MongoDbGenericRepository.MongoDbContext.GetCollectionName``1(System.String)">
<summary>
Drops a collection having a partitionkey, use very carefully.
Given the docmuent type and the partition key, returns the name of the collection it belongs to.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="partitionKey">The value of the partition key.</param>
<returns>The name of the collection.</returns>
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.Pluralize``1">
<summary>
Very naively pluralizes a TDocument type name.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<returns></returns>
<returns>The pluralized document name.</returns>
</member>
<member name="T:MongoDbGenericRepository.ReadOnlyMongoRepository">
<summary>
@@ -1713,6 +2155,43 @@
<param name="filter">A LINQ expression filter.</param>
<param name="partitionKey">An optional partitionKey</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMaxAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="maxValueSelector">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMax``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="maxValueSelector">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
<returns></returns>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMinAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMin``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByIdAsync``2(``1,System.String)">
<summary>
Asynchronously returns one document given its id.
@@ -1812,21 +2291,159 @@
<param name="filter">A LINQ expression filter.</param>
<param name="partitionKey">An optional partitionKey</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMaxAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="maxValueSelector">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMax``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="maxValueSelector">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMinAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMin``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMinMongoQuery``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMaxMongoQuery``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="maxValueSelector">A property selector to order by descending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMaxValueAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="maxValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMaxValueAsync``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMaxValue``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="maxValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMaxValue``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="maxValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMinValueAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMinValueAsync``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMinValue``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMinValue``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetCollection``1(System.String)">
<summary>
Gets a collections for the type TDocument with the matching partition key.
Gets a collections for the type TDocument with the matching partition key (if any).
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="partitionKey">The partion key.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>An <see cref="T:MongoDB.Driver.IMongoCollection`1"/></returns>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetCollection``1">
<summary>
Gets a collections for the type TDocument
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<returns></returns>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.HandlePartitioned``1(``0)">
<summary>
Gets a collections for the type TDocument
@@ -1870,6 +2487,26 @@
<param name="partitionKey">The collection partition key.</param>
<returns></returns>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.ConvertExpression``2(System.Linq.Expressions.Expression{System.Func{``0,``1}})">
<summary>
Converts a LINQ expression of TDocument, TValue to a LINQ expression of TDocument, object
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TValue">The type of the value.</typeparam>
<param name="expression">The expression to convert</param>
</member>
<member name="T:MongoDbGenericRepository.Utils.IdGenerator">
<summary>
The IdGenerator instance, used to generate Ids of different types.
</summary>
</member>
<member name="M:MongoDbGenericRepository.Utils.IdGenerator.GetId``1">
<summary>
Generates a random value of a given type.
</summary>
<typeparam name="TKey">The type of the value to generate.</typeparam>
<returns>A value of type TKey.</returns>
</member>
<member name="T:MongoDbGenericRepository.Utils.Vocabularies">
<summary>
Container for registered Vocabularies. At present, only a single vocabulary is supported: Default.
@@ -1,7 +1,7 @@
{
"runtimeTarget": {
"name": ".NETStandard,Version=v1.5/",
"signature": "795a70ab1bbc13177859af16f1887befe3221c54"
"signature": "b945d8e228876adfa8e84019c7873fce5baf0c0b"
},
"compilationOptions": {},
"targets": {
@@ -9,7 +9,7 @@
".NETStandard,Version=v1.5/": {
"MongoDbGenericRepository/1.0.0": {
"dependencies": {
"MongoDB.Driver": "2.5.0",
"MongoDB.Driver": "2.7.0",
"NETStandard.Library": "1.6.1"
},
"runtime": {
@@ -60,7 +60,7 @@
"System.Runtime.InteropServices": "4.3.0"
}
},
"MongoDB.Bson/2.5.0": {
"MongoDB.Bson/2.7.0": {
"dependencies": {
"NETStandard.Library": "1.6.1",
"System.Collections.NonGeneric": "4.0.1",
@@ -72,10 +72,10 @@
"lib/netstandard1.5/MongoDB.Bson.dll": {}
}
},
"MongoDB.Driver/2.5.0": {
"MongoDB.Driver/2.7.0": {
"dependencies": {
"MongoDB.Bson": "2.5.0",
"MongoDB.Driver.Core": "2.5.0",
"MongoDB.Bson": "2.7.0",
"MongoDB.Driver.Core": "2.7.0",
"NETStandard.Library": "1.6.1",
"System.ComponentModel.TypeConverter": "4.1.0",
"System.Linq.Queryable": "4.0.1"
@@ -84,10 +84,10 @@
"lib/netstandard1.5/MongoDB.Driver.dll": {}
}
},
"MongoDB.Driver.Core/2.5.0": {
"MongoDB.Driver.Core/2.7.0": {
"dependencies": {
"DnsClient": "1.0.7",
"MongoDB.Bson": "2.5.0",
"MongoDB.Bson": "2.7.0",
"NETStandard.Library": "1.6.1",
"System.Collections.Specialized": "4.0.1",
"System.Diagnostics.TraceSource": "4.0.0",
@@ -1021,26 +1021,26 @@
"path": "microsoft.win32.registry/4.0.0",
"hashPath": "microsoft.win32.registry.4.0.0.nupkg.sha512"
},
"MongoDB.Bson/2.5.0": {
"MongoDB.Bson/2.7.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-b7zQAUdSdfJ4kmGzAA+hv89N2Q6jm1td9WfTimgp8xWAsN4qbtIjA/JkAY1HA0Z8xfXQE3EmdUcDEwT8bkXfXg==",
"path": "mongodb.bson/2.5.0",
"hashPath": "mongodb.bson.2.5.0.nupkg.sha512"
"sha512": "sha512-vzpTDHYX/X6gF9qtDuKRJiLkqpj5OZuT1bIzJCiBiU8CwJ37becYmaXuy/QSuWnYN6j6ZdVTWILKbWt2MXL8DA==",
"path": "mongodb.bson/2.7.0",
"hashPath": "mongodb.bson.2.7.0.nupkg.sha512"
},
"MongoDB.Driver/2.5.0": {
"MongoDB.Driver/2.7.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-VbHVV8Xdl3PcPU3XxdOUE/yc4BnPokg7k1XHU/3fEM/UdfCy0Ie0eXVE+U2HJXVcM3TQuuyVn+B1La2YY7X8dA==",
"path": "mongodb.driver/2.5.0",
"hashPath": "mongodb.driver.2.5.0.nupkg.sha512"
"sha512": "sha512-5wP5BBwm5YO6h2Vhw6zQmOwSW9WP2d6kgRM6E7uIbwIJz4+j2trS2Wo7/+IYow5WVN8Jd6O27bIB/4gKNepO1Q==",
"path": "mongodb.driver/2.7.0",
"hashPath": "mongodb.driver.2.7.0.nupkg.sha512"
},
"MongoDB.Driver.Core/2.5.0": {
"MongoDB.Driver.Core/2.7.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-/JYwBTEoWZDHiSePk0AF775c0YkSGSsHTA2+hWt9/UOCkYV/QOFujAWDdpFzBMCDpmQewbLRR1knYj76YOxffA==",
"path": "mongodb.driver.core/2.5.0",
"hashPath": "mongodb.driver.core.2.5.0.nupkg.sha512"
"sha512": "sha512-SepB4KT+zXA3iFaIFwXVKmk6BZIp0EGE/iWqNbDZ1mca9e8EhtqYPwOOzFmEbdKAzmVvF1y86kNI4agWP6I5sg==",
"path": "mongodb.driver.core/2.7.0",
"hashPath": "mongodb.driver.core.2.7.0.nupkg.sha512"
},
"NETStandard.Library/1.6.1": {
"type": "package",
@@ -141,6 +141,7 @@
<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.UpdateOneAsync``1(``0,MongoDB.Driver.UpdateDefinition{``0})">
<summary>
@@ -155,11 +156,11 @@
For the entity 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.UpdateOne``1(``0,MongoDB.Driver.UpdateDefinition{``0})">
<summary>
@@ -213,6 +214,7 @@
<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.UpdateOneAsync``3(``0,System.Linq.Expressions.Expression{System.Func{``0,``2}},``2)">
<summary>
@@ -235,6 +237,7 @@
<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.UpdateOne``3(``0,System.Linq.Expressions.Expression{System.Func{``0,``2}},``2)">
<summary>
@@ -566,6 +569,170 @@
<param name="projection">The projected group result.</param>
<param name="partitionKey">The partition key of your document, if any.</param>
</member>
<member name="T:MongoDbGenericRepository.IMongoDbCollectionIndexRepository">
<summary>
The repository interface for managing indexes
</summary>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateTextIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Create a text index on the given field.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateTextIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Create a text index on the given field.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateAscendingIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates an index on the given field in ascending order.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateAscendingIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates an index on the given field in ascending order.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateDescendingIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates an index on the given field in descending order.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>A string containing the result of the operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateDescendingIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates an index on the given field in descending order.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateHashedIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates a hashed index on the given field.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>A string containing the result of the operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateHashedIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates a hashed index on the given field.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateCombinedTextIndexAsync``1(System.Collections.Generic.IEnumerable{System.Linq.Expressions.Expression{System.Func{``0,System.Object}}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates a combined text index.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="fields">The fields we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateCombinedTextIndexAsync``2(System.Collections.Generic.IEnumerable{System.Linq.Expressions.Expression{System.Func{``0,System.Object}}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates a combined text index.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="fields">The fields we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.DropIndexAsync``1(System.String,System.String)">
<summary>
Drops the index given a field name
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="indexName">The name of the index</param>
<param name="partitionKey">An optional partition key</param>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.DropIndexAsync``2(System.String,System.String)">
<summary>
Drops the index given a field name
</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="indexName">The name of the index</param>
<param name="partitionKey">An optional partition key</param>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.GetIndexesNamesAsync``1(System.String)">
<summary>
Returns the names of the indexes present on a collection.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="partitionKey">An optional partition key</param>
<returns>A list containing the names of the indexes on on the concerned collection.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.GetIndexesNamesAsync``2(System.String)">
<summary>
Returns the names of the indexes present on a collection.
</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="partitionKey">An optional partition key</param>
<returns>A list containing the names of the indexes on on the concerned collection.</returns>
</member>
<member name="T:MongoDbGenericRepository.IMongoDbContext">
<summary>
This is the interface of the IMongoDbContext which is managed by the <see cref="T:MongoDbGenericRepository.BaseMongoRepository"/>.
@@ -588,20 +755,6 @@
<typeparam name="TDocument"></typeparam>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbContext.GetCollection``2(System.String)">
<summary>
Returns a collection for a document type that has a partition key.
</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="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbContext.DropCollection``1">
<summary>
Drops a collection, use very carefully.
</summary>
<typeparam name="TDocument"></typeparam>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbContext.DropCollection``1(System.String)">
<summary>
Drops a collection having a partitionkey, use very carefully.
@@ -816,6 +969,165 @@
<param name="filter">A LINQ expression filter.</param>
<param name="partitionKey">An optional partitionKey</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMaxAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByDescending">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMax``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByDescending">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
<returns></returns>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMinAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMin``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMaxAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMax``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMinAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMin``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMaxValueAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="maxValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMaxValueAsync``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMaxValue``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="maxValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMaxValue``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMinValueAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMinValueAsync``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMinValue``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMinValue``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="T:MongoDbGenericRepository.Attributes.CollectionNameAttribute">
<summary>
This attribute allows you to specify of the name of the collection.
@@ -830,11 +1142,21 @@
The name of the collection in which your documents are stored.
</summary>
</member>
<member name="M:MongoDbGenericRepository.Attributes.CollectionNameAttribute.#ctor(System.String)">
<summary>
The constructor.
</summary>
<param name="name">The name of the collection.</param>
</member>
<member name="T:MongoDbGenericRepository.BaseMongoRepository">
<summary>
The base Repository, it is meant to be inherited from by your custom custom MongoRepository implementation.
Its constructor must be given a connection string and a database name.
</summary>
<summary>
The base Repository, it is meant to be inherited from by your custom custom MongoRepository implementation.
Its constructor must be given a connection string and a database name.
</summary>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.#ctor(System.String,System.String)">
<summary>
@@ -985,6 +1307,7 @@
<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.UpdateOneAsync``2(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
@@ -1002,11 +1325,11 @@
For the entity 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.UpdateOne``1(``0,MongoDB.Driver.UpdateDefinition{``0})">
<summary>
@@ -1094,6 +1417,7 @@
<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.UpdateOne``3(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
@@ -1117,6 +1441,7 @@
<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.DeleteOneAsync``1(``0)">
<summary>
@@ -1428,6 +1753,48 @@
<typeparam name="TDocument">The document type.</typeparam>
<param name="document">The document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateTextIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateTextIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateAscendingIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateAscendingIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateDescendingIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateDescendingIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateHashedIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateHashedIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateCombinedTextIndexAsync``1(System.Collections.Generic.IEnumerable{System.Linq.Expressions.Expression{System.Func{``0,System.Object}}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateCombinedTextIndexAsync``2(System.Collections.Generic.IEnumerable{System.Linq.Expressions.Expression{System.Func{``0,System.Object}}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.DropIndexAsync``1(System.String,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.DropIndexAsync``2(System.String,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.GetIndexesNamesAsync``1(System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.GetIndexesNamesAsync``2(System.String)">
<inheritdoc />
</member>
<member name="T:MongoDbGenericRepository.Models.Document">
<summary>
This class represents a basic document that can be stored in MongoDb.
@@ -1477,6 +1844,81 @@
Your document must implement this class in order for the MongoDbRepository to handle them.
</summary>
</member>
<member name="T:MongoDbGenericRepository.Models.IndexCreationOptions">
<summary>
Options for creating an index.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Unique">
<summary>
Gets or sets a value indicating whether the index is a unique index.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.TextIndexVersion">
<summary>
Gets or sets the index version for text indexes.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.SphereIndexVersion">
<summary>
Gets or sets the index version for 2dsphere indexes.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Sparse">
<summary>
Gets or sets a value indicating whether the index is a sparse index.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Name">
<summary>
Gets or sets the index name.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Min">
<summary>
Gets or sets the min value for 2d indexes.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Max">
<summary>
Gets or sets the max value for 2d indexes.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.LanguageOverride">
<summary>
Gets or sets the language override.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.ExpireAfter">
<summary>
Gets or sets when documents expire (used with TTL indexes).
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.DefaultLanguage">
<summary>
Gets or sets the default language.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.BucketSize">
<summary>
Gets or sets the size of a geohash bucket.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Bits">
<summary>
Gets or sets the precision, in bits, used with geohash indexes.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Background">
<summary>
Gets or sets a value indicating whether to create the index in the background.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Version">
<summary>
Gets or sets the version of the index.
</summary>
</member>
<member name="T:MongoDbGenericRepository.Models.IPartitionedDocument">
<summary>
This class represents a document that can be inserted in a collection that can be partitioned.
@@ -1532,6 +1974,12 @@
</summary>
<param name="guidRepresentation">The new value of the GuidRepresentation</param>
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.InitializeGuidRepresentation">
<summary>
Initialize the Guid representation of the MongoDb Driver.
Override this method to change the default GuidRepresentation.
</summary>
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.#ctor(MongoDB.Driver.IMongoDatabase)">
<summary>
The constructor of the MongoDbContext, it needs a an object implementing <see cref="T:MongoDB.Driver.IMongoDatabase"/>.
@@ -1554,37 +2002,31 @@
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.GetCollection``1(System.String)">
<summary>
Returns a collection for a document type that has a partition key.
Returns a collection for a document type. Also handles document types with a partition key.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="partitionKey">The value of the partition key.</param>
<param name="partitionKey">The optional value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.GetCollection``2(System.String)">
<summary>
Returns a collection for a document type that has a partition key.
</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="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.DropCollection``1">
<member name="M:MongoDbGenericRepository.MongoDbContext.DropCollection``1(System.String)">
<summary>
Drops a collection, use very carefully.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.DropCollection``1(System.String)">
<member name="M:MongoDbGenericRepository.MongoDbContext.GetCollectionName``1(System.String)">
<summary>
Drops a collection having a partitionkey, use very carefully.
Given the docmuent type and the partition key, returns the name of the collection it belongs to.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="partitionKey">The value of the partition key.</param>
<returns>The name of the collection.</returns>
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.Pluralize``1">
<summary>
Very naively pluralizes a TDocument type name.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<returns></returns>
<returns>The pluralized document name.</returns>
</member>
<member name="T:MongoDbGenericRepository.ReadOnlyMongoRepository">
<summary>
@@ -1713,6 +2155,43 @@
<param name="filter">A LINQ expression filter.</param>
<param name="partitionKey">An optional partitionKey</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMaxAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="maxValueSelector">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMax``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="maxValueSelector">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
<returns></returns>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMinAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMin``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByIdAsync``2(``1,System.String)">
<summary>
Asynchronously returns one document given its id.
@@ -1812,21 +2291,159 @@
<param name="filter">A LINQ expression filter.</param>
<param name="partitionKey">An optional partitionKey</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMaxAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="maxValueSelector">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMax``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="maxValueSelector">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMinAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMin``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMinMongoQuery``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMaxMongoQuery``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="maxValueSelector">A property selector to order by descending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMaxValueAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="maxValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMaxValueAsync``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMaxValue``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="maxValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMaxValue``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="maxValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMinValueAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMinValueAsync``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMinValue``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMinValue``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetCollection``1(System.String)">
<summary>
Gets a collections for the type TDocument with the matching partition key.
Gets a collections for the type TDocument with the matching partition key (if any).
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="partitionKey">The partion key.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>An <see cref="T:MongoDB.Driver.IMongoCollection`1"/></returns>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetCollection``1">
<summary>
Gets a collections for the type TDocument
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<returns></returns>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.HandlePartitioned``1(``0)">
<summary>
Gets a collections for the type TDocument
@@ -1870,6 +2487,26 @@
<param name="partitionKey">The collection partition key.</param>
<returns></returns>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.ConvertExpression``2(System.Linq.Expressions.Expression{System.Func{``0,``1}})">
<summary>
Converts a LINQ expression of TDocument, TValue to a LINQ expression of TDocument, object
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TValue">The type of the value.</typeparam>
<param name="expression">The expression to convert</param>
</member>
<member name="T:MongoDbGenericRepository.Utils.IdGenerator">
<summary>
The IdGenerator instance, used to generate Ids of different types.
</summary>
</member>
<member name="M:MongoDbGenericRepository.Utils.IdGenerator.GetId``1">
<summary>
Generates a random value of a given type.
</summary>
<typeparam name="TKey">The type of the value to generate.</typeparam>
<returns>A value of type TKey.</returns>
</member>
<member name="T:MongoDbGenericRepository.Utils.Vocabularies">
<summary>
Container for registered Vocabularies. At present, only a single vocabulary is supported: Default.
@@ -1,7 +1,7 @@
{
"runtimeTarget": {
"name": ".NETStandard,Version=v2.0/",
"signature": "c7b8ca9e84d3f282de57dfcebff465cb47d24ac8"
"signature": "af81df2668beb4b8f166ddd0c4c0f1882e8ec745"
},
"compilationOptions": {},
"targets": {
@@ -9,8 +9,8 @@
".NETStandard,Version=v2.0/": {
"MongoDbGenericRepository/1.0.0": {
"dependencies": {
"MongoDB.Driver": "2.5.0",
"NETStandard.Library": "2.0.1"
"MongoDB.Driver": "2.7.0",
"NETStandard.Library": "2.0.3"
},
"runtime": {
"MongoDbGenericRepository.dll": {}
@@ -19,7 +19,7 @@
"DnsClient/1.0.7": {
"dependencies": {
"Microsoft.Win32.Primitives": "4.3.0",
"NETStandard.Library": "2.0.1",
"NETStandard.Library": "2.0.3",
"System.Buffers": "4.3.0",
"System.Collections": "4.3.0",
"System.Collections.Concurrent": "4.3.0",
@@ -60,9 +60,9 @@
"System.Runtime.InteropServices": "4.3.0"
}
},
"MongoDB.Bson/2.5.0": {
"MongoDB.Bson/2.7.0": {
"dependencies": {
"NETStandard.Library": "2.0.1",
"NETStandard.Library": "2.0.3",
"System.Collections.NonGeneric": "4.0.1",
"System.Diagnostics.Process": "4.1.0",
"System.Dynamic.Runtime": "4.0.11",
@@ -72,11 +72,11 @@
"lib/netstandard1.5/MongoDB.Bson.dll": {}
}
},
"MongoDB.Driver/2.5.0": {
"MongoDB.Driver/2.7.0": {
"dependencies": {
"MongoDB.Bson": "2.5.0",
"MongoDB.Driver.Core": "2.5.0",
"NETStandard.Library": "2.0.1",
"MongoDB.Bson": "2.7.0",
"MongoDB.Driver.Core": "2.7.0",
"NETStandard.Library": "2.0.3",
"System.ComponentModel.TypeConverter": "4.1.0",
"System.Linq.Queryable": "4.0.1"
},
@@ -84,11 +84,11 @@
"lib/netstandard1.5/MongoDB.Driver.dll": {}
}
},
"MongoDB.Driver.Core/2.5.0": {
"MongoDB.Driver.Core/2.7.0": {
"dependencies": {
"DnsClient": "1.0.7",
"MongoDB.Bson": "2.5.0",
"NETStandard.Library": "2.0.1",
"MongoDB.Bson": "2.7.0",
"NETStandard.Library": "2.0.3",
"System.Collections.Specialized": "4.0.1",
"System.Diagnostics.TraceSource": "4.0.0",
"System.Net.NameResolution": "4.3.0",
@@ -99,7 +99,7 @@
"lib/netstandard1.5/MongoDB.Driver.Core.dll": {}
}
},
"NETStandard.Library/2.0.1": {
"NETStandard.Library/2.0.3": {
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0"
}
@@ -926,33 +926,33 @@
"path": "microsoft.win32.registry/4.0.0",
"hashPath": "microsoft.win32.registry.4.0.0.nupkg.sha512"
},
"MongoDB.Bson/2.5.0": {
"MongoDB.Bson/2.7.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-b7zQAUdSdfJ4kmGzAA+hv89N2Q6jm1td9WfTimgp8xWAsN4qbtIjA/JkAY1HA0Z8xfXQE3EmdUcDEwT8bkXfXg==",
"path": "mongodb.bson/2.5.0",
"hashPath": "mongodb.bson.2.5.0.nupkg.sha512"
"sha512": "sha512-vzpTDHYX/X6gF9qtDuKRJiLkqpj5OZuT1bIzJCiBiU8CwJ37becYmaXuy/QSuWnYN6j6ZdVTWILKbWt2MXL8DA==",
"path": "mongodb.bson/2.7.0",
"hashPath": "mongodb.bson.2.7.0.nupkg.sha512"
},
"MongoDB.Driver/2.5.0": {
"MongoDB.Driver/2.7.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-VbHVV8Xdl3PcPU3XxdOUE/yc4BnPokg7k1XHU/3fEM/UdfCy0Ie0eXVE+U2HJXVcM3TQuuyVn+B1La2YY7X8dA==",
"path": "mongodb.driver/2.5.0",
"hashPath": "mongodb.driver.2.5.0.nupkg.sha512"
"sha512": "sha512-5wP5BBwm5YO6h2Vhw6zQmOwSW9WP2d6kgRM6E7uIbwIJz4+j2trS2Wo7/+IYow5WVN8Jd6O27bIB/4gKNepO1Q==",
"path": "mongodb.driver/2.7.0",
"hashPath": "mongodb.driver.2.7.0.nupkg.sha512"
},
"MongoDB.Driver.Core/2.5.0": {
"MongoDB.Driver.Core/2.7.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-/JYwBTEoWZDHiSePk0AF775c0YkSGSsHTA2+hWt9/UOCkYV/QOFujAWDdpFzBMCDpmQewbLRR1knYj76YOxffA==",
"path": "mongodb.driver.core/2.5.0",
"hashPath": "mongodb.driver.core.2.5.0.nupkg.sha512"
"sha512": "sha512-SepB4KT+zXA3iFaIFwXVKmk6BZIp0EGE/iWqNbDZ1mca9e8EhtqYPwOOzFmEbdKAzmVvF1y86kNI4agWP6I5sg==",
"path": "mongodb.driver.core/2.7.0",
"hashPath": "mongodb.driver.core.2.7.0.nupkg.sha512"
},
"NETStandard.Library/2.0.1": {
"NETStandard.Library/2.0.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-oA6nwv9MhEKYvLpjZ0ggSpb1g4CQViDVQjLUcDWg598jtvJbpfeP2reqwI1GLW2TbxC/Ml7xL6BBR1HmKPXlTg==",
"path": "netstandard.library/2.0.1",
"hashPath": "netstandard.library.2.0.1.nupkg.sha512"
"sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
"path": "netstandard.library/2.0.3",
"hashPath": "netstandard.library.2.0.3.nupkg.sha512"
},
"runtime.native.System/4.3.0": {
"type": "package",
@@ -141,6 +141,7 @@
<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.UpdateOneAsync``1(``0,MongoDB.Driver.UpdateDefinition{``0})">
<summary>
@@ -155,11 +156,11 @@
For the entity 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.UpdateOne``1(``0,MongoDB.Driver.UpdateDefinition{``0})">
<summary>
@@ -213,6 +214,7 @@
<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.UpdateOneAsync``3(``0,System.Linq.Expressions.Expression{System.Func{``0,``2}},``2)">
<summary>
@@ -235,6 +237,7 @@
<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.UpdateOne``3(``0,System.Linq.Expressions.Expression{System.Func{``0,``2}},``2)">
<summary>
@@ -566,6 +569,170 @@
<param name="projection">The projected group result.</param>
<param name="partitionKey">The partition key of your document, if any.</param>
</member>
<member name="T:MongoDbGenericRepository.IMongoDbCollectionIndexRepository">
<summary>
The repository interface for managing indexes
</summary>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateTextIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Create a text index on the given field.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateTextIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Create a text index on the given field.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateAscendingIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates an index on the given field in ascending order.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateAscendingIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates an index on the given field in ascending order.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateDescendingIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates an index on the given field in descending order.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>A string containing the result of the operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateDescendingIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates an index on the given field in descending order.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateHashedIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates a hashed index on the given field.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>A string containing the result of the operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateHashedIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates a hashed index on the given field.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="field">The field we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateCombinedTextIndexAsync``1(System.Collections.Generic.IEnumerable{System.Linq.Expressions.Expression{System.Func{``0,System.Object}}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates a combined text index.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="fields">The fields we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.CreateCombinedTextIndexAsync``2(System.Collections.Generic.IEnumerable{System.Linq.Expressions.Expression{System.Func{``0,System.Object}}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<summary>
Creates a combined text index.
IndexCreationOptions can be supplied to further specify
how the creation should be done.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<typeparam name="TKey">The type of the primary key for a Document.</typeparam>
<param name="fields">The fields we want to index.</param>
<param name="indexCreationOptions">Options for creating an index.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>The result of the create index operation.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.DropIndexAsync``1(System.String,System.String)">
<summary>
Drops the index given a field name
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="indexName">The name of the index</param>
<param name="partitionKey">An optional partition key</param>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.DropIndexAsync``2(System.String,System.String)">
<summary>
Drops the index given a field name
</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="indexName">The name of the index</param>
<param name="partitionKey">An optional partition key</param>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.GetIndexesNamesAsync``1(System.String)">
<summary>
Returns the names of the indexes present on a collection.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="partitionKey">An optional partition key</param>
<returns>A list containing the names of the indexes on on the concerned collection.</returns>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbCollectionIndexRepository.GetIndexesNamesAsync``2(System.String)">
<summary>
Returns the names of the indexes present on a collection.
</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="partitionKey">An optional partition key</param>
<returns>A list containing the names of the indexes on on the concerned collection.</returns>
</member>
<member name="T:MongoDbGenericRepository.IMongoDbContext">
<summary>
This is the interface of the IMongoDbContext which is managed by the <see cref="T:MongoDbGenericRepository.BaseMongoRepository"/>.
@@ -588,20 +755,6 @@
<typeparam name="TDocument"></typeparam>
<param name="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbContext.GetCollection``2(System.String)">
<summary>
Returns a collection for a document type that has a partition key.
</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="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbContext.DropCollection``1">
<summary>
Drops a collection, use very carefully.
</summary>
<typeparam name="TDocument"></typeparam>
</member>
<member name="M:MongoDbGenericRepository.IMongoDbContext.DropCollection``1(System.String)">
<summary>
Drops a collection having a partitionkey, use very carefully.
@@ -816,6 +969,165 @@
<param name="filter">A LINQ expression filter.</param>
<param name="partitionKey">An optional partitionKey</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMaxAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByDescending">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMax``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByDescending">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
<returns></returns>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMinAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMin``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMaxAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMax``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMinAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetByMin``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMaxValueAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="maxValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMaxValueAsync``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMaxValue``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="maxValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMaxValue``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMinValueAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMinValueAsync``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMinValue``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.IReadOnlyMongoRepository.GetMinValue``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="T:MongoDbGenericRepository.Attributes.CollectionNameAttribute">
<summary>
This attribute allows you to specify of the name of the collection.
@@ -830,11 +1142,21 @@
The name of the collection in which your documents are stored.
</summary>
</member>
<member name="M:MongoDbGenericRepository.Attributes.CollectionNameAttribute.#ctor(System.String)">
<summary>
The constructor.
</summary>
<param name="name">The name of the collection.</param>
</member>
<member name="T:MongoDbGenericRepository.BaseMongoRepository">
<summary>
The base Repository, it is meant to be inherited from by your custom custom MongoRepository implementation.
Its constructor must be given a connection string and a database name.
</summary>
<summary>
The base Repository, it is meant to be inherited from by your custom custom MongoRepository implementation.
Its constructor must be given a connection string and a database name.
</summary>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.#ctor(System.String,System.String)">
<summary>
@@ -985,6 +1307,7 @@
<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.UpdateOneAsync``2(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},``1,System.String)">
<summary>
@@ -1002,11 +1325,11 @@
For the entity 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.UpdateOne``1(``0,MongoDB.Driver.UpdateDefinition{``0})">
<summary>
@@ -1094,6 +1417,7 @@
<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.UpdateOne``3(MongoDB.Driver.FilterDefinition{``0},System.Linq.Expressions.Expression{System.Func{``0,``2}},``2,System.String)">
<summary>
@@ -1117,6 +1441,7 @@
<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.DeleteOneAsync``1(``0)">
<summary>
@@ -1428,6 +1753,48 @@
<typeparam name="TDocument">The document type.</typeparam>
<param name="document">The document.</param>
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateTextIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateTextIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateAscendingIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateAscendingIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateDescendingIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateDescendingIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateHashedIndexAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateHashedIndexAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Object}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateCombinedTextIndexAsync``1(System.Collections.Generic.IEnumerable{System.Linq.Expressions.Expression{System.Func{``0,System.Object}}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.CreateCombinedTextIndexAsync``2(System.Collections.Generic.IEnumerable{System.Linq.Expressions.Expression{System.Func{``0,System.Object}}},MongoDbGenericRepository.Models.IndexCreationOptions,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.DropIndexAsync``1(System.String,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.DropIndexAsync``2(System.String,System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.GetIndexesNamesAsync``1(System.String)">
<inheritdoc />
</member>
<member name="M:MongoDbGenericRepository.BaseMongoRepository.GetIndexesNamesAsync``2(System.String)">
<inheritdoc />
</member>
<member name="T:MongoDbGenericRepository.Models.Document">
<summary>
This class represents a basic document that can be stored in MongoDb.
@@ -1477,6 +1844,81 @@
Your document must implement this class in order for the MongoDbRepository to handle them.
</summary>
</member>
<member name="T:MongoDbGenericRepository.Models.IndexCreationOptions">
<summary>
Options for creating an index.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Unique">
<summary>
Gets or sets a value indicating whether the index is a unique index.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.TextIndexVersion">
<summary>
Gets or sets the index version for text indexes.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.SphereIndexVersion">
<summary>
Gets or sets the index version for 2dsphere indexes.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Sparse">
<summary>
Gets or sets a value indicating whether the index is a sparse index.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Name">
<summary>
Gets or sets the index name.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Min">
<summary>
Gets or sets the min value for 2d indexes.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Max">
<summary>
Gets or sets the max value for 2d indexes.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.LanguageOverride">
<summary>
Gets or sets the language override.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.ExpireAfter">
<summary>
Gets or sets when documents expire (used with TTL indexes).
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.DefaultLanguage">
<summary>
Gets or sets the default language.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.BucketSize">
<summary>
Gets or sets the size of a geohash bucket.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Bits">
<summary>
Gets or sets the precision, in bits, used with geohash indexes.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Background">
<summary>
Gets or sets a value indicating whether to create the index in the background.
</summary>
</member>
<member name="P:MongoDbGenericRepository.Models.IndexCreationOptions.Version">
<summary>
Gets or sets the version of the index.
</summary>
</member>
<member name="T:MongoDbGenericRepository.Models.IPartitionedDocument">
<summary>
This class represents a document that can be inserted in a collection that can be partitioned.
@@ -1532,6 +1974,12 @@
</summary>
<param name="guidRepresentation">The new value of the GuidRepresentation</param>
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.InitializeGuidRepresentation">
<summary>
Initialize the Guid representation of the MongoDb Driver.
Override this method to change the default GuidRepresentation.
</summary>
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.#ctor(MongoDB.Driver.IMongoDatabase)">
<summary>
The constructor of the MongoDbContext, it needs a an object implementing <see cref="T:MongoDB.Driver.IMongoDatabase"/>.
@@ -1554,37 +2002,31 @@
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.GetCollection``1(System.String)">
<summary>
Returns a collection for a document type that has a partition key.
Returns a collection for a document type. Also handles document types with a partition key.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="partitionKey">The value of the partition key.</param>
<param name="partitionKey">The optional value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.GetCollection``2(System.String)">
<summary>
Returns a collection for a document type that has a partition key.
</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="partitionKey">The value of the partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.DropCollection``1">
<member name="M:MongoDbGenericRepository.MongoDbContext.DropCollection``1(System.String)">
<summary>
Drops a collection, use very carefully.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.DropCollection``1(System.String)">
<member name="M:MongoDbGenericRepository.MongoDbContext.GetCollectionName``1(System.String)">
<summary>
Drops a collection having a partitionkey, use very carefully.
Given the docmuent type and the partition key, returns the name of the collection it belongs to.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<param name="partitionKey">The value of the partition key.</param>
<returns>The name of the collection.</returns>
</member>
<member name="M:MongoDbGenericRepository.MongoDbContext.Pluralize``1">
<summary>
Very naively pluralizes a TDocument type name.
</summary>
<typeparam name="TDocument">The type representing a Document.</typeparam>
<returns></returns>
<returns>The pluralized document name.</returns>
</member>
<member name="T:MongoDbGenericRepository.ReadOnlyMongoRepository">
<summary>
@@ -1713,6 +2155,43 @@
<param name="filter">A LINQ expression filter.</param>
<param name="partitionKey">An optional partitionKey</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMaxAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="maxValueSelector">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMax``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="maxValueSelector">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
<returns></returns>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMinAsync``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMin``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByIdAsync``2(``1,System.String)">
<summary>
Asynchronously returns one document given its id.
@@ -1812,21 +2291,159 @@
<param name="filter">A LINQ expression filter.</param>
<param name="partitionKey">An optional partitionKey</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMaxAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="maxValueSelector">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMax``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="maxValueSelector">A property selector to order by descending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMinAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetByMin``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Object}},System.String)">
<summary>
Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMinMongoQuery``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMaxMongoQuery``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="maxValueSelector">A property selector to order by descending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMaxValueAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="maxValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMaxValueAsync``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TKey">The type of the primary key.</typeparam>
<param name="filter">A LINQ expression filter.</param>
<param name="orderByAscending">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMaxValue``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="maxValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMaxValue``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="maxValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partitionKey.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMinValueAsync``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMinValueAsync``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMinValue``2(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetMinValue``3(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,``2}},System.String)">
<summary>
Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
</summary>
<typeparam name="TDocument">The document type.</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>
<param name="filter">A LINQ expression filter.</param>
<param name="minValueSelector">A property selector to order by ascending.</param>
<param name="partitionKey">An optional partition key.</param>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetCollection``1(System.String)">
<summary>
Gets a collections for the type TDocument with the matching partition key.
Gets a collections for the type TDocument with the matching partition key (if any).
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<param name="partitionKey">The partion key.</param>
<param name="partitionKey">An optional partition key.</param>
<returns>An <see cref="T:MongoDB.Driver.IMongoCollection`1"/></returns>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.GetCollection``1">
<summary>
Gets a collections for the type TDocument
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<returns></returns>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.HandlePartitioned``1(``0)">
<summary>
Gets a collections for the type TDocument
@@ -1870,6 +2487,26 @@
<param name="partitionKey">The collection partition key.</param>
<returns></returns>
</member>
<member name="M:MongoDbGenericRepository.ReadOnlyMongoRepository.ConvertExpression``2(System.Linq.Expressions.Expression{System.Func{``0,``1}})">
<summary>
Converts a LINQ expression of TDocument, TValue to a LINQ expression of TDocument, object
</summary>
<typeparam name="TDocument">The document type.</typeparam>
<typeparam name="TValue">The type of the value.</typeparam>
<param name="expression">The expression to convert</param>
</member>
<member name="T:MongoDbGenericRepository.Utils.IdGenerator">
<summary>
The IdGenerator instance, used to generate Ids of different types.
</summary>
</member>
<member name="M:MongoDbGenericRepository.Utils.IdGenerator.GetId``1">
<summary>
Generates a random value of a given type.
</summary>
<typeparam name="TKey">The type of the value to generate.</typeparam>
<returns>A value of type TKey.</returns>
</member>
<member name="T:MongoDbGenericRepository.Utils.Vocabularies">
<summary>
Container for registered Vocabularies. At present, only a single vocabulary is supported: Default.
+19 -2
View File
@@ -40,6 +40,7 @@ Here is an example of repository usage, where the TestRepository is implementing
}
}
```
## Instantiation
The repository can be instantiated like so:
@@ -127,6 +128,22 @@ _testRepository.AddOne(myDoc);
The above code will generate a collection named `myPartitionKey-myPartitionedDocuments`.
## CollectionName Attribute
It is now possible to change the collection name by using the `CollectionName` attribute:
```csharp
[CollectionName("MyCollectionName")]
public class MyDocument : Document
{
public MyDocument()
{
Version = 2;
}
public string SomeContent { get; set; }
}
```
Documents of this type will be inserted into a collection named "MyCollectionName".
Please refer to the IntegrationTests (NET45) and CoreIntegrationTests (netstandard2.0) projects for more usage examples.
## Author
@@ -137,7 +154,7 @@ mongodb-generic-repository is under MIT license - http://www.opensource.org/lice
The MIT License (MIT)
Copyright (c) 2016-2017 Alexandre Spieser
Copyright (c) 2016-2018 Alexandre Spieser
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -172,4 +189,4 @@ Copyright (c) 2012-2014 Mehdi Khalili (http://omar.io)
==============================================================================
## Copyright
Copyright © 2017
Copyright © 2018