diff --git a/CoreIntegrationTests/CoreIntegrationTests.csproj b/CoreIntegrationTests/CoreIntegrationTests.csproj index 720179b..2a2e786 100644 --- a/CoreIntegrationTests/CoreIntegrationTests.csproj +++ b/CoreIntegrationTests/CoreIntegrationTests.csproj @@ -9,16 +9,13 @@ + - - - - ..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Configuration.dll diff --git a/CoreIntegrationTests/Infrastructure/MongoDbDocumentTestBase.cs b/CoreIntegrationTests/Infrastructure/MongoDbDocumentTestBase.cs index eb98474..2734c35 100644 --- a/CoreIntegrationTests/Infrastructure/MongoDbDocumentTestBase.cs +++ b/CoreIntegrationTests/Infrastructure/MongoDbDocumentTestBase.cs @@ -846,6 +846,94 @@ namespace CoreIntegrationTests.Infrastructure 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(documents); + var expectedMin = documents.OrderBy(e => e.Nested.SomeDate).First(); + + // Act + var result = SUT.GetMinValue(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(documents); + var expectedMin = documents.OrderBy(e => e.Nested.SomeDate).First(); + + // Act + var result = await SUT.GetMinValueAsync(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(documents); + var expectedMax = documents.OrderByDescending(e => e.Nested.SomeDate).First(); + + // Act + var result = SUT.GetMaxValue(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(documents); + var expectedMin = documents.OrderByDescending(e => e.Nested.SomeDate).First(); + + // Act + var result = await SUT.GetMaxValueAsync(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 Test Utils diff --git a/CoreIntegrationTests/Infrastructure/MongoDbTKeyDocumentTestBase.cs b/CoreIntegrationTests/Infrastructure/MongoDbTKeyDocumentTestBase.cs index af0a2b3..056163f 100644 --- a/CoreIntegrationTests/Infrastructure/MongoDbTKeyDocumentTestBase.cs +++ b/CoreIntegrationTests/Infrastructure/MongoDbTKeyDocumentTestBase.cs @@ -891,6 +891,50 @@ namespace CoreIntegrationTests.Infrastructure 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(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(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 Test Utils diff --git a/IntegrationTests/IntegrationTests.csproj b/IntegrationTests/IntegrationTests.csproj index 65d3b75..f64fc49 100644 --- a/IntegrationTests/IntegrationTests.csproj +++ b/IntegrationTests/IntegrationTests.csproj @@ -30,22 +30,34 @@ 4 + + ..\packages\MongoDbGenericRepository.1.3.7\lib\net45\DnsClient.dll + - ..\packages\MongoDB.Bson.2.7.0\lib\net45\MongoDB.Bson.dll + ..\packages\MongoDbGenericRepository.1.3.7\lib\net45\MongoDB.Bson.dll - ..\packages\MongoDB.Driver.2.7.0\lib\net45\MongoDB.Driver.dll + ..\packages\MongoDbGenericRepository.1.3.7\lib\net45\MongoDB.Driver.dll - ..\packages\MongoDB.Driver.Core.2.7.0\lib\net45\MongoDB.Driver.Core.dll + ..\packages\MongoDbGenericRepository.1.3.7\lib\net45\MongoDB.Driver.Core.dll + + + ..\packages\MongoDbGenericRepository.1.3.7\lib\net45\MongoDbGenericRepository.dll ..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll + + ..\packages\MongoDbGenericRepository.1.3.7\lib\net45\System.Buffers.dll + + + ..\packages\MongoDbGenericRepository.1.3.7\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll + @@ -74,11 +86,5 @@ - - - {efc776c4-2af3-440c-be80-3fbe335817a5} - MongoDbGenericRepository - - \ No newline at end of file diff --git a/IntegrationTests/packages.config b/IntegrationTests/packages.config index af7ff01..a65fee1 100644 --- a/IntegrationTests/packages.config +++ b/IntegrationTests/packages.config @@ -4,6 +4,7 @@ + diff --git a/MongoDbGenericRepository/Abstractions/IReadOnlyMongoRepository.cs b/MongoDbGenericRepository/Abstractions/IReadOnlyMongoRepository.cs index 4010e8b..2632d66 100644 --- a/MongoDbGenericRepository/Abstractions/IReadOnlyMongoRepository.cs +++ b/MongoDbGenericRepository/Abstractions/IReadOnlyMongoRepository.cs @@ -111,47 +111,6 @@ namespace MongoDbGenericRepository /// An optional partition key. long Count(Expression> filter, string partitionKey = null) where TDocument : IDocument; - /// - /// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. - /// - /// The document type. - /// A LINQ expression filter. - /// A property selector to order by descending. - /// An optional partitionKey. - Task GetByMaxAsync(Expression> filter, Expression> orderByDescending, string partitionKey = null) - where TDocument : IDocument; - - /// - /// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. - /// - /// The document type. - /// A LINQ expression filter. - /// A property selector to order by descending. - /// An optional partitionKey. - /// - TDocument GetByMax(Expression> filter, Expression> orderByDescending, string partitionKey = null) - where TDocument : IDocument; - - /// - /// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. - /// - /// The document type. - /// A LINQ expression filter. - /// A property selector to order by ascending. - /// An optional partitionKey. - Task GetByMinAsync(Expression> filter, Expression> orderByAscending, string partitionKey = null) - where TDocument : IDocument; - - /// - /// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. - /// - /// The document type. - /// A LINQ expression filter. - /// A property selector to order by ascending. - /// An optional partitionKey. - TDocument GetByMin(Expression> filter, Expression> orderByAscending, string partitionKey = null) - where TDocument : IDocument; - #endregion #region Read TKey @@ -278,6 +237,51 @@ namespace MongoDbGenericRepository where TDocument : IDocument where TKey : IEquatable; + #endregion + + #region Min / Max + + /// + /// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + /// + /// The document type. + /// A LINQ expression filter. + /// A property selector to order by descending. + /// An optional partitionKey. + Task GetByMaxAsync(Expression> filter, Expression> orderByDescending, string partitionKey = null) + where TDocument : IDocument; + + /// + /// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + /// + /// The document type. + /// A LINQ expression filter. + /// A property selector to order by descending. + /// An optional partitionKey. + /// + TDocument GetByMax(Expression> filter, Expression> orderByDescending, string partitionKey = null) + where TDocument : IDocument; + + /// + /// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + /// + /// The document type. + /// A LINQ expression filter. + /// A property selector to order by ascending. + /// An optional partitionKey. + Task GetByMinAsync(Expression> filter, Expression> orderByAscending, string partitionKey = null) + where TDocument : IDocument; + + /// + /// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + /// + /// The document type. + /// A LINQ expression filter. + /// A property selector to order by ascending. + /// An optional partitionKey. + TDocument GetByMin(Expression> filter, Expression> orderByAscending, string partitionKey = null) + where TDocument : IDocument; + /// /// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. /// @@ -326,6 +330,17 @@ namespace MongoDbGenericRepository where TDocument : IDocument where TKey : IEquatable; + /// + /// Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + /// + /// The document type. + /// The type of the value used to order the query. + /// A LINQ expression filter. + /// A property selector to order by ascending. + /// An optional partitionKey. + Task GetMaxValueAsync(Expression> filter, Expression> maxValueSelector, string partitionKey = null) + where TDocument : IDocument; + /// /// Gets the maximum value of a property in a mongodb collections that is satisfying the filter. /// @@ -338,6 +353,17 @@ namespace MongoDbGenericRepository where TDocument : IDocument where TKey : IEquatable; + /// + /// Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + /// + /// The document type. + /// The type of the value used to order the query. + /// A LINQ expression filter. + /// A property selector to order by ascending. + /// An optional partitionKey. + TValue GetMaxValue(Expression> filter, Expression> maxValueSelector, string partitionKey = null) + where TDocument : IDocument; + /// /// Gets the maximum value of a property in a mongodb collections that is satisfying the filter. /// @@ -350,6 +376,54 @@ namespace MongoDbGenericRepository where TDocument : IDocument where TKey : IEquatable; + /// + /// Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + /// + /// The document type. + /// The type of the value used to order the query. + /// A LINQ expression filter. + /// A property selector to order by ascending. + /// An optional partition key. + Task GetMinValueAsync(Expression> filter, Expression> minValueSelector, string partitionKey = null) + where TDocument : IDocument; + + /// + /// Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + /// + /// The document type. + /// The type of the primary key. + /// The type of the value used to order the query. + /// A LINQ expression filter. + /// A property selector to order by ascending. + /// An optional partition key. + Task GetMinValueAsync(Expression> filter, Expression> minValueSelector, string partitionKey = null) + where TDocument : IDocument + where TKey : IEquatable; + + /// + /// Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + /// + /// The document type. + /// The type of the value used to order the query. + /// A LINQ expression filter. + /// A property selector to order by ascending. + /// An optional partition key. + TValue GetMinValue(Expression> filter, Expression> minValueSelector, string partitionKey = null) + where TDocument : IDocument; + + /// + /// Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + /// + /// The document type. + /// The type of the primary key. + /// The type of the value used to order the query. + /// A LINQ expression filter. + /// A property selector to order by ascending. + /// An optional partition key. + TValue GetMinValue(Expression> filter, Expression> minValueSelector, string partitionKey = null) + where TDocument : IDocument + where TKey : IEquatable; + #endregion } diff --git a/MongoDbGenericRepository/MongoDbContext.cs b/MongoDbGenericRepository/MongoDbContext.cs index d30f3a3..ccb2379 100644 --- a/MongoDbGenericRepository/MongoDbContext.cs +++ b/MongoDbGenericRepository/MongoDbContext.cs @@ -80,7 +80,7 @@ namespace MongoDbGenericRepository /// Returns a collection for a document type. Also handles document types with a partition key. /// /// The type representing a Document. - /// The value of the partition key. + /// The optional value of the partition key. public IMongoCollection GetCollection(string partitionKey = null) { return Database.GetCollection(GetCollectionName(partitionKey)); @@ -95,21 +95,27 @@ namespace MongoDbGenericRepository Database.DropCollection(GetCollectionName(partitionKey)); } + /// + /// Given the docmuent type and the partition key, returns the name of the collection it belongs to. + /// + /// The type representing a Document. + /// The value of the partition key. + /// The name of the collection. private string GetCollectionName(string partitionKey) { + var collectionName = GetAttributeCollectionName() ?? Pluralize(); if (string.IsNullOrEmpty(partitionKey)) { - return GetAttributeCollectionName() ?? Pluralize(); + return collectionName; } - var collectionName = $"{partitionKey}-{(GetAttributeCollectionName() ?? Pluralize())}"; - return collectionName; + return $"{partitionKey}-{collectionName}"; } /// /// Very naively pluralizes a TDocument type name. /// /// The type representing a Document. - /// + /// The pluralized document name. private string Pluralize() { return (typeof(TDocument).Name.Pluralize()).Camelize(); diff --git a/MongoDbGenericRepository/MongoDbGenericRepository.nuspec b/MongoDbGenericRepository/MongoDbGenericRepository.nuspec index 405505b..44154e1 100644 --- a/MongoDbGenericRepository/MongoDbGenericRepository.nuspec +++ b/MongoDbGenericRepository/MongoDbGenericRepository.nuspec @@ -10,8 +10,8 @@ https://github.com/alexandre-spieser/mongodb-generic-repository false A generic repository implementation using the MongoDB C# Sharp 2.0 driver. - Upgraded dependencies. - Copyright 2017 (c) Alexandre Spieser. All rights reserved. + Upgraded dependencies. Full support for bulk insertion and deletion of documents of the same type but with different partitionkey values. Added methods for Min and Max queries. + Copyright 2018 (c) Alexandre Spieser. All rights reserved. MongoDb Repository Generic NoSql diff --git a/MongoDbGenericRepository/ReadOnlyMongoRepository.cs b/MongoDbGenericRepository/ReadOnlyMongoRepository.cs index 8fadda8..0a8adb9 100644 --- a/MongoDbGenericRepository/ReadOnlyMongoRepository.cs +++ b/MongoDbGenericRepository/ReadOnlyMongoRepository.cs @@ -188,14 +188,12 @@ namespace MongoDbGenericRepository /// /// The document type. /// A LINQ expression filter. - /// A property selector to order by descending. + /// A property selector to order by descending. /// An optional partitionKey. - public async Task GetByMaxAsync(Expression> filter, Expression> orderByDescending, string partitionKey = null) + public async Task GetByMaxAsync(Expression> filter, Expression> maxValueSelector, string partitionKey = null) where TDocument : IDocument { - return await GetCollection(partitionKey).Find(Builders.Filter.Where(filter)) - .SortByDescending(orderByDescending) - .FirstOrDefaultAsync(); + return await GetByMaxAsync(filter, maxValueSelector, partitionKey); } /// @@ -203,15 +201,13 @@ namespace MongoDbGenericRepository /// /// The document type. /// A LINQ expression filter. - /// A property selector to order by descending. + /// A property selector to order by descending. /// An optional partitionKey. /// - public TDocument GetByMax(Expression> filter, Expression> orderByDescending, string partitionKey = null) + public TDocument GetByMax(Expression> filter, Expression> maxValueSelector, string partitionKey = null) where TDocument : IDocument { - return GetCollection(partitionKey).Find(Builders.Filter.Where(filter)) - .SortByDescending(orderByDescending) - .FirstOrDefault(); + return GetByMax(filter, maxValueSelector, partitionKey); } /// @@ -219,14 +215,12 @@ namespace MongoDbGenericRepository /// /// The document type. /// A LINQ expression filter. - /// A property selector to order by ascending. + /// A property selector to order by ascending. /// An optional partitionKey. - public async Task GetByMinAsync(Expression> filter, Expression> orderByAscending, string partitionKey = null) + public async Task GetByMinAsync(Expression> filter, Expression> minValueSelector, string partitionKey = null) where TDocument : IDocument { - return await GetCollection(partitionKey).Find(Builders.Filter.Where(filter)) - .SortBy(orderByAscending) - .FirstOrDefaultAsync(); + return await GetByMinAsync(filter, minValueSelector, partitionKey); } /// @@ -239,9 +233,7 @@ namespace MongoDbGenericRepository public TDocument GetByMin(Expression> filter, Expression> orderByAscending, string partitionKey = null) where TDocument : IDocument { - return GetCollection(partitionKey).Find(Builders.Filter.Where(filter)) - .SortBy(orderByAscending) - .FirstOrDefault(); + return GetByMin(filter, orderByAscending, partitionKey); } #endregion @@ -412,14 +404,15 @@ namespace MongoDbGenericRepository /// The document type. /// The type of the primary key. /// A LINQ expression filter. - /// A property selector to order by descending. + /// A property selector to order by descending. /// An optional partitionKey. - public async Task GetByMaxAsync(Expression> filter, Expression> orderByDescending, string partitionKey = null) + public async Task GetByMaxAsync(Expression> filter, Expression> maxValueSelector, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable { return await GetCollection(partitionKey).Find(Builders.Filter.Where(filter)) - .SortByDescending(orderByDescending) + .SortByDescending(maxValueSelector) + .Limit(1) .FirstOrDefaultAsync(); } @@ -429,14 +422,15 @@ namespace MongoDbGenericRepository /// The document type. /// The type of the primary key. /// A LINQ expression filter. - /// A property selector to order by descending. + /// A property selector to order by descending. /// An optional partitionKey. - public TDocument GetByMax(Expression> filter, Expression> orderByDescending, string partitionKey = null) + public TDocument GetByMax(Expression> filter, Expression> maxValueSelector, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable { return GetCollection(partitionKey).Find(Builders.Filter.Where(filter)) - .SortByDescending(orderByDescending) + .SortByDescending(maxValueSelector) + .Limit(1) .FirstOrDefault(); } @@ -446,14 +440,15 @@ namespace MongoDbGenericRepository /// The document type. /// The type of the primary key. /// A LINQ expression filter. - /// A property selector to order by ascending. + /// A property selector to order by ascending. /// An optional partitionKey. - public async Task GetByMinAsync(Expression> filter, Expression> orderByAscending, string partitionKey = null) + public async Task GetByMinAsync(Expression> filter, Expression> minValueSelector, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable { return await GetCollection(partitionKey).Find(Builders.Filter.Where(filter)) - .SortBy(orderByAscending) + .SortBy(minValueSelector) + .Limit(1) .FirstOrDefaultAsync(); } @@ -463,17 +458,68 @@ namespace MongoDbGenericRepository /// The document type. /// The type of the primary key. /// A LINQ expression filter. - /// A property selector to order by ascending. + /// A property selector to order by ascending. /// An optional partitionKey. - public TDocument GetByMin(Expression> filter, Expression> orderByAscending, string partitionKey = null) + public TDocument GetByMin(Expression> filter, Expression> minValueSelector, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable { return GetCollection(partitionKey).Find(Builders.Filter.Where(filter)) - .SortBy(orderByAscending) + .SortBy(minValueSelector) + .Limit(1) .FirstOrDefault(); } + /// + /// Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + /// + /// The document type. + /// The type of the primary key. + /// The type of the value used to order the query. + /// A LINQ expression filter. + /// A property selector to order by ascending. + /// An optional partition key. + private IFindFluent GetMinMongoQuery(Expression> filter, Expression> minValueSelector, string partitionKey = null) + where TDocument : IDocument + where TKey : IEquatable + { + return GetCollection(partitionKey).Find(Builders.Filter.Where(filter)) + .SortBy(ConvertExpression(minValueSelector)) + .Limit(1); + } + + /// + /// Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + /// + /// The document type. + /// The type of the primary key. + /// The type of the value used to order the query. + /// A LINQ expression filter. + /// A property selector to order by descending. + /// An optional partition key. + private IFindFluent GetMaxMongoQuery(Expression> filter, Expression> maxValueSelector, string partitionKey = null) + where TDocument : IDocument + where TKey : IEquatable + { + return GetCollection(partitionKey).Find(Builders.Filter.Where(filter)) + .SortByDescending(ConvertExpression(maxValueSelector)) + .Limit(1); + } + + /// + /// Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + /// + /// The document type. + /// The type of the value used to order the query. + /// A LINQ expression filter. + /// A property selector to order by ascending. + /// An optional partitionKey. + public async Task GetMaxValueAsync(Expression> filter, Expression> maxValueSelector, string partitionKey = null) + where TDocument : IDocument + { + return await GetMaxValueAsync(filter, maxValueSelector, partitionKey); + } + /// /// Gets the maximum value of a property in a mongodb collections that is satisfying the filter. /// @@ -486,10 +532,23 @@ namespace MongoDbGenericRepository where TDocument : IDocument where TKey : IEquatable { - return await GetCollection(partitionKey).Find(Builders.Filter.Where(filter)) - .SortByDescending(ConvertExpression(maxValueSelector)) - .Project(maxValueSelector) - .FirstOrDefaultAsync(); + return await GetMaxMongoQuery(filter, maxValueSelector, partitionKey) + .Project(maxValueSelector) + .FirstOrDefaultAsync(); + } + + /// + /// Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + /// + /// The document type. + /// The type of the value used to order the query. + /// A LINQ expression filter. + /// A property selector to order by ascending. + /// An optional partitionKey. + public TValue GetMaxValue(Expression> filter, Expression> maxValueSelector, string partitionKey = null) + where TDocument : IDocument + { + return GetMaxValue(filter, maxValueSelector, partitionKey); } /// @@ -497,18 +556,78 @@ namespace MongoDbGenericRepository /// /// The document type. /// The type of the primary key. + /// The type of the value used to order the query. /// A LINQ expression filter. - /// A property selector to order by ascending. + /// A property selector to order by ascending. /// An optional partitionKey. - public TValue GetMaxValue(Expression> filter, Expression> orderByDescending, string partitionKey = null) + public TValue GetMaxValue(Expression> filter, Expression> maxValueSelector, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable { - return GetCollection(partitionKey).Find(Builders.Filter.Where(filter)) - .SortByDescending(ConvertExpression(orderByDescending)) - .Project(orderByDescending) - .FirstOrDefault(); + return GetMaxMongoQuery(filter, maxValueSelector, partitionKey) + .Project(maxValueSelector) + .FirstOrDefault(); + } + + /// + /// Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + /// + /// The document type. + /// The type of the value used to order the query. + /// A LINQ expression filter. + /// A property selector to order by ascending. + /// An optional partition key. + public async Task GetMinValueAsync(Expression> filter, Expression> minValueSelector, string partitionKey = null) + where TDocument : IDocument + { + return await GetMinValueAsync(filter, minValueSelector, partitionKey); + } + + /// + /// Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + /// + /// The document type. + /// The type of the primary key. + /// The type of the value used to order the query. + /// A LINQ expression filter. + /// A property selector to order by ascending. + /// An optional partition key. + public async Task GetMinValueAsync(Expression> filter, Expression> minValueSelector, string partitionKey = null) + where TDocument : IDocument + where TKey : IEquatable + { + return await GetMinMongoQuery(filter, minValueSelector, partitionKey).Project(minValueSelector).FirstOrDefaultAsync(); + } + + /// + /// Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + /// + /// The document type. + /// The type of the value used to order the query. + /// A LINQ expression filter. + /// A property selector to order by ascending. + /// An optional partition key. + public TValue GetMinValue(Expression> filter, Expression> minValueSelector, string partitionKey = null) + where TDocument : IDocument + { + return GetMinValue(filter, minValueSelector, partitionKey); + } + + /// + /// Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + /// + /// The document type. + /// The type of the primary key. + /// The type of the value used to order the query. + /// A LINQ expression filter. + /// A property selector to order by ascending. + /// An optional partition key. + public TValue GetMinValue(Expression> filter, Expression> minValueSelector, string partitionKey = null) + where TDocument : IDocument + where TKey : IEquatable + { + return GetMinMongoQuery(filter, minValueSelector, partitionKey).Project(minValueSelector).FirstOrDefault(); } #endregion @@ -516,26 +635,16 @@ namespace MongoDbGenericRepository #region Utility Methods /// - /// 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). /// /// The document type. - /// The partion key. + /// An optional partition key. /// An - protected IMongoCollection GetCollection(string partitionKey) where TDocument : IDocument + protected IMongoCollection GetCollection(string partitionKey = null) where TDocument : IDocument { return MongoDbContext.GetCollection(partitionKey); } - /// - /// Gets a collections for the type TDocument - /// - /// The document type. - /// - protected IMongoCollection GetCollection() where TDocument : IDocument - { - return MongoDbContext.GetCollection(); - } - /// /// Gets a collections for the type TDocument /// diff --git a/MongoDbGenericRepository/lib/net45/MongoDB.Bson.dll b/MongoDbGenericRepository/lib/net45/MongoDB.Bson.dll index 94d16e1..b2d4d12 100644 Binary files a/MongoDbGenericRepository/lib/net45/MongoDB.Bson.dll and b/MongoDbGenericRepository/lib/net45/MongoDB.Bson.dll differ diff --git a/MongoDbGenericRepository/lib/net45/MongoDB.Driver.Core.dll b/MongoDbGenericRepository/lib/net45/MongoDB.Driver.Core.dll index 26139c8..fec0581 100644 Binary files a/MongoDbGenericRepository/lib/net45/MongoDB.Driver.Core.dll and b/MongoDbGenericRepository/lib/net45/MongoDB.Driver.Core.dll differ diff --git a/MongoDbGenericRepository/lib/net45/MongoDB.Driver.dll b/MongoDbGenericRepository/lib/net45/MongoDB.Driver.dll index 04e2e13..bbad91f 100644 Binary files a/MongoDbGenericRepository/lib/net45/MongoDB.Driver.dll and b/MongoDbGenericRepository/lib/net45/MongoDB.Driver.dll differ diff --git a/MongoDbGenericRepository/lib/net45/MongoDbGenericRepository.dll b/MongoDbGenericRepository/lib/net45/MongoDbGenericRepository.dll index f0d0e37..4af4809 100644 Binary files a/MongoDbGenericRepository/lib/net45/MongoDbGenericRepository.dll and b/MongoDbGenericRepository/lib/net45/MongoDbGenericRepository.dll differ diff --git a/MongoDbGenericRepository/lib/net45/MongoDbGenericRepository.xml b/MongoDbGenericRepository/lib/net45/MongoDbGenericRepository.xml index f599a93..bfd5e60 100644 --- a/MongoDbGenericRepository/lib/net45/MongoDbGenericRepository.xml +++ b/MongoDbGenericRepository/lib/net45/MongoDbGenericRepository.xml @@ -591,20 +591,6 @@ The value of the partition key. - - - Returns a collection for a document type that has a partition key. - - The type representing a Document. - The type of the primary key for a Document. - The value of the partition key. - - - - Drops a collection, use very carefully. - - - Drops a collection having a partitionkey, use very carefully. @@ -819,6 +805,165 @@ A LINQ expression filter. An optional partitionKey + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + This attribute allows you to specify of the name of the collection. @@ -1544,6 +1689,12 @@ The new value of the GuidRepresentation + + + Initialize the Guid representation of the MongoDb Driver. + Override this method to change the default GuidRepresentation. + + The constructor of the MongoDbContext, it needs a an object implementing . @@ -1566,37 +1717,31 @@ - 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. The type representing a Document. - The value of the partition key. + The optional value of the partition key. - - - Returns a collection for a document type that has a partition key. - - The type representing a Document. - The type of the primary key for a Document. - The value of the partition key. - - + Drops a collection, use very carefully. The type representing a Document. - + - 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. The type representing a Document. + The value of the partition key. + The name of the collection. Very naively pluralizes a TDocument type name. The type representing a Document. - + The pluralized document name. @@ -1725,6 +1870,43 @@ A LINQ expression filter. An optional partitionKey + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + Asynchronously returns one document given its id. @@ -1824,21 +2006,159 @@ A LINQ expression filter. An optional partitionKey + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by descending. + An optional partition key. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + - 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). The document type. - The partion key. + An optional partition key. An - - - Gets a collections for the type TDocument - - The document type. - - Gets a collections for the type TDocument @@ -1882,6 +2202,14 @@ The collection partition key. + + + Converts a LINQ expression of TDocument, TValue to a LINQ expression of TDocument, object + + The document type. + The type of the value. + The expression to convert + The IdGenerator instance, used to generate Ids of different types. diff --git a/MongoDbGenericRepository/lib/netstandard1.5/MongoDbGenericRepository.deps.json b/MongoDbGenericRepository/lib/netstandard1.5/MongoDbGenericRepository.deps.json index fbb76ef..e5ec7b9 100644 --- a/MongoDbGenericRepository/lib/netstandard1.5/MongoDbGenericRepository.deps.json +++ b/MongoDbGenericRepository/lib/netstandard1.5/MongoDbGenericRepository.deps.json @@ -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", diff --git a/MongoDbGenericRepository/lib/netstandard1.5/MongoDbGenericRepository.dll b/MongoDbGenericRepository/lib/netstandard1.5/MongoDbGenericRepository.dll index c198950..2ad890d 100644 Binary files a/MongoDbGenericRepository/lib/netstandard1.5/MongoDbGenericRepository.dll and b/MongoDbGenericRepository/lib/netstandard1.5/MongoDbGenericRepository.dll differ diff --git a/MongoDbGenericRepository/lib/netstandard1.5/MongoDbGenericRepository.xml b/MongoDbGenericRepository/lib/netstandard1.5/MongoDbGenericRepository.xml index f599a93..bfd5e60 100644 --- a/MongoDbGenericRepository/lib/netstandard1.5/MongoDbGenericRepository.xml +++ b/MongoDbGenericRepository/lib/netstandard1.5/MongoDbGenericRepository.xml @@ -591,20 +591,6 @@ The value of the partition key. - - - Returns a collection for a document type that has a partition key. - - The type representing a Document. - The type of the primary key for a Document. - The value of the partition key. - - - - Drops a collection, use very carefully. - - - Drops a collection having a partitionkey, use very carefully. @@ -819,6 +805,165 @@ A LINQ expression filter. An optional partitionKey + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + This attribute allows you to specify of the name of the collection. @@ -1544,6 +1689,12 @@ The new value of the GuidRepresentation + + + Initialize the Guid representation of the MongoDb Driver. + Override this method to change the default GuidRepresentation. + + The constructor of the MongoDbContext, it needs a an object implementing . @@ -1566,37 +1717,31 @@ - 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. The type representing a Document. - The value of the partition key. + The optional value of the partition key. - - - Returns a collection for a document type that has a partition key. - - The type representing a Document. - The type of the primary key for a Document. - The value of the partition key. - - + Drops a collection, use very carefully. The type representing a Document. - + - 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. The type representing a Document. + The value of the partition key. + The name of the collection. Very naively pluralizes a TDocument type name. The type representing a Document. - + The pluralized document name. @@ -1725,6 +1870,43 @@ A LINQ expression filter. An optional partitionKey + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + Asynchronously returns one document given its id. @@ -1824,21 +2006,159 @@ A LINQ expression filter. An optional partitionKey + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by descending. + An optional partition key. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + - 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). The document type. - The partion key. + An optional partition key. An - - - Gets a collections for the type TDocument - - The document type. - - Gets a collections for the type TDocument @@ -1882,6 +2202,14 @@ The collection partition key. + + + Converts a LINQ expression of TDocument, TValue to a LINQ expression of TDocument, object + + The document type. + The type of the value. + The expression to convert + The IdGenerator instance, used to generate Ids of different types. diff --git a/MongoDbGenericRepository/lib/netstandard2.0/MongoDbGenericRepository.deps.json b/MongoDbGenericRepository/lib/netstandard2.0/MongoDbGenericRepository.deps.json index 297295c..1328c4a 100644 --- a/MongoDbGenericRepository/lib/netstandard2.0/MongoDbGenericRepository.deps.json +++ b/MongoDbGenericRepository/lib/netstandard2.0/MongoDbGenericRepository.deps.json @@ -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", diff --git a/MongoDbGenericRepository/lib/netstandard2.0/MongoDbGenericRepository.dll b/MongoDbGenericRepository/lib/netstandard2.0/MongoDbGenericRepository.dll index 3af9dbc..74a53ea 100644 Binary files a/MongoDbGenericRepository/lib/netstandard2.0/MongoDbGenericRepository.dll and b/MongoDbGenericRepository/lib/netstandard2.0/MongoDbGenericRepository.dll differ diff --git a/MongoDbGenericRepository/lib/netstandard2.0/MongoDbGenericRepository.xml b/MongoDbGenericRepository/lib/netstandard2.0/MongoDbGenericRepository.xml index f599a93..bfd5e60 100644 --- a/MongoDbGenericRepository/lib/netstandard2.0/MongoDbGenericRepository.xml +++ b/MongoDbGenericRepository/lib/netstandard2.0/MongoDbGenericRepository.xml @@ -591,20 +591,6 @@ The value of the partition key. - - - Returns a collection for a document type that has a partition key. - - The type representing a Document. - The type of the primary key for a Document. - The value of the partition key. - - - - Drops a collection, use very carefully. - - - Drops a collection having a partitionkey, use very carefully. @@ -819,6 +805,165 @@ A LINQ expression filter. An optional partitionKey + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + This attribute allows you to specify of the name of the collection. @@ -1544,6 +1689,12 @@ The new value of the GuidRepresentation + + + Initialize the Guid representation of the MongoDb Driver. + Override this method to change the default GuidRepresentation. + + The constructor of the MongoDbContext, it needs a an object implementing . @@ -1566,37 +1717,31 @@ - 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. The type representing a Document. - The value of the partition key. + The optional value of the partition key. - - - Returns a collection for a document type that has a partition key. - - The type representing a Document. - The type of the primary key for a Document. - The value of the partition key. - - + Drops a collection, use very carefully. The type representing a Document. - + - 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. The type representing a Document. + The value of the partition key. + The name of the collection. Very naively pluralizes a TDocument type name. The type representing a Document. - + The pluralized document name. @@ -1725,6 +1870,43 @@ A LINQ expression filter. An optional partitionKey + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + Asynchronously returns one document given its id. @@ -1824,21 +2006,159 @@ A LINQ expression filter. An optional partitionKey + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by descending. + An optional partitionKey. + + + + Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by descending. + An optional partition key. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the maximum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partitionKey. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + + + + Gets the minimum value of a property in a mongodb collections that is satisfying the filter. + + The document type. + The type of the primary key. + The type of the value used to order the query. + A LINQ expression filter. + A property selector to order by ascending. + An optional partition key. + - 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). The document type. - The partion key. + An optional partition key. An - - - Gets a collections for the type TDocument - - The document type. - - Gets a collections for the type TDocument @@ -1882,6 +2202,14 @@ The collection partition key. + + + Converts a LINQ expression of TDocument, TValue to a LINQ expression of TDocument, object + + The document type. + The type of the value. + The expression to convert + The IdGenerator instance, used to generate Ids of different types.