diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Apps/MongoAppRepository.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Apps/MongoAppRepository.cs index 485aa75de..0fb277ae6 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Apps/MongoAppRepository.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Apps/MongoAppRepository.cs @@ -48,7 +48,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Apps { using (Telemetry.Activities.StartActivity("MongoAppRepository/QueryIdsAsync")) { - var find = Collection.Find(x => x.IndexedUserIds.Contains(contributorId) && !x.IndexedDeleted).SortBy(x => x.IndexedCreated); + var find = Collection.Find(x => x.IndexedUserIds.Contains(contributorId) && !x.IndexedDeleted); return await QueryAsync(find, ct); } @@ -59,7 +59,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Apps { using (Telemetry.Activities.StartActivity("MongoAppRepository/QueryAsync")) { - var find = Collection.Find(x => names.Contains(x.IndexedName) && !x.IndexedDeleted).SortBy(x => x.IndexedCreated); + var find = Collection.Find(x => names.Contains(x.IndexedName) && !x.IndexedDeleted); return await QueryAsync(find, ct); } @@ -68,7 +68,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Apps private static async Task> QueryAsync(IFindFluent find, CancellationToken ct) { - var entities = await find.Only(x => x.DocumentId, x => x.IndexedName).ToListAsync(ct); + var entities = await find.SortBy(x => x.IndexedCreated).Only(x => x.DocumentId, x => x.IndexedName).ToListAsync(ct); var result = new Dictionary(); @@ -77,10 +77,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Apps var indexedId = DomainId.Create(entity["_id"].AsString); var indexedName = entity["_an"].AsString; - if (!result.ContainsKey(indexedName)) - { - result.Add(indexedName, indexedId); - } + result[indexedName] = indexedId; } return result; diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Schemas/MongoSchemaRepository.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Schemas/MongoSchemaRepository.cs index 86150c2a9..0480ef56c 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Schemas/MongoSchemaRepository.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Schemas/MongoSchemaRepository.cs @@ -46,7 +46,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Schemas { using (Telemetry.Activities.StartActivity("MongoSchemaRepository/QueryAsync")) { - var find = Collection.Find(x => x.IndexedAppId == appId && !x.IndexedDeleted).SortBy(x => x.IndexedCreated); + var find = Collection.Find(x => x.IndexedAppId == appId && !x.IndexedDeleted); return await QueryAsync(find, ct); } @@ -55,7 +55,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Schemas private static async Task> QueryAsync(IFindFluent find, CancellationToken ct) { - var entities = await find.Only(x => x.IndexedId, x => x.IndexedName).ToListAsync(ct); + var entities = await find.SortBy(x => x.IndexedCreated).Only(x => x.IndexedId, x => x.IndexedName).ToListAsync(ct); var result = new Dictionary(); @@ -64,10 +64,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Schemas var indexedId = DomainId.Create(entity["_si"].AsString); var indexedName = entity["_sn"].AsString; - if (!result.ContainsKey(indexedName)) - { - result.Add(indexedName, indexedId); - } + result[indexedName] = indexedId; } return result;