From 8c2e8834e16c0fc747561256a8597b0f8a9e88c7 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 24 Oct 2022 21:00:40 +0800 Subject: [PATCH] Improve the performance when `totalCount` is 0. Resolve #14228 --- .../Services/AbstractKeyReadOnlyAppService.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AbstractKeyReadOnlyAppService.cs b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AbstractKeyReadOnlyAppService.cs index b3aa8e43a4..e56e3ff042 100644 --- a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AbstractKeyReadOnlyAppService.cs +++ b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AbstractKeyReadOnlyAppService.cs @@ -63,14 +63,19 @@ public abstract class AbstractKeyReadOnlyAppService(); + var entityDtos = new List(); + + if (totalCount > 0) + { + query = ApplySorting(query, input); + query = ApplyPaging(query, input); - var entities = await AsyncExecuter.ToListAsync(query); - var entityDtos = await MapToGetListOutputDtosAsync(entities); + entities = await AsyncExecuter.ToListAsync(query); + entityDtos = await MapToGetListOutputDtosAsync(entities); + } return new PagedResultDto( totalCount,