From 1bda765d3d16bf31626ccd2fe8f7b2f287764fa7 Mon Sep 17 00:00:00 2001 From: Lukas Nagel Date: Wed, 9 Aug 2023 19:07:09 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Updated=20to=20IEnumerable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Interfaces/IMongoDbRepository.cs | 6 +--- .../Repositories/MongoDbRepository.cs | 29 ++----------------- 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/Fedodo.NuGet.Common/Interfaces/IMongoDbRepository.cs b/Fedodo.NuGet.Common/Interfaces/IMongoDbRepository.cs index 38bf21d..3d36f48 100644 --- a/Fedodo.NuGet.Common/Interfaces/IMongoDbRepository.cs +++ b/Fedodo.NuGet.Common/Interfaces/IMongoDbRepository.cs @@ -26,11 +26,7 @@ public Task> GetSpecificPaged(string databaseName, string coll public Task> GetAllPagedFromCollections(string databaseName, string collectionName, int pageId, int pageSize, SortDefinition sortDefinition, string foreignCollectionName); - public Task> GetSpecificPagedFromCollections(string databaseName, string collectionName, - int pageId, int pageSize, SortDefinition sortDefinition, string foreignCollectionName, - FilterDefinition filter); - - public Task CountSpecificFromCollections(string databaseName, List collectionNames, + public Task CountSpecificFromCollections(string databaseName, IEnumerable collectionNames, FilterDefinition filter); public Task> GetSpecificPagedFromCollections(string databaseName, diff --git a/Fedodo.NuGet.Common/Repositories/MongoDbRepository.cs b/Fedodo.NuGet.Common/Repositories/MongoDbRepository.cs index 90ec238..3b25835 100644 --- a/Fedodo.NuGet.Common/Repositories/MongoDbRepository.cs +++ b/Fedodo.NuGet.Common/Repositories/MongoDbRepository.cs @@ -95,30 +95,7 @@ public async Task> GetAllPagedFromCollections(string databaseN return result; } - - public async Task> GetSpecificPagedFromCollections(string databaseName, string collectionName, - int pageId, int pageSize, SortDefinition sortDefinition, string foreignCollectionName, - FilterDefinition filter) - { - _logger.LogTrace($"Getting specific items paged of type: {typeof(T)}"); - - var database = _client.GetDatabase(databaseName); - var collection = database.GetCollection(collectionName); - var foreignCollection = database.GetCollection(foreignCollectionName); - - var result = await collection.Aggregate() - .UnionWith(foreignCollection) - .Match(filter) - .Sort(sortDefinition) - .Skip(pageId * pageSize) - .Limit(pageSize) - .ToListAsync(); - - _logger.LogTrace($"Finished getting specific items paged of type: {typeof(T)}"); - - return result; - } - + public async Task> GetSpecificPaged(string databaseName, string collectionName, int pageId, int pageSize, SortDefinition sortDefinition, FilterDefinition filter) @@ -187,13 +164,13 @@ public async Task CountSpecific(string databaseName, string collectionN return result; } - public async Task CountSpecificFromCollections(string databaseName, List collectionNames, + public async Task CountSpecificFromCollections(string databaseName, IEnumerable collectionNames, FilterDefinition filter) { _logger.LogTrace($"Counting all items of type: {typeof(T)} in {nameof(CountSpecificFromCollections)}"); var database = _client.GetDatabase(databaseName); - var collection = AggregateCollections(collectionNames, database); + var collection = AggregateCollections(collectionNames.ToList(), database); var result = (await collection.Match(filter).Count().FirstOrDefaultAsync()).Count;