diff --git a/src/Umbraco.Core/Services/EntityService.cs b/src/Umbraco.Core/Services/EntityService.cs index 6ba02cc880..fe779507c4 100644 --- a/src/Umbraco.Core/Services/EntityService.cs +++ b/src/Umbraco.Core/Services/EntityService.cs @@ -440,7 +440,7 @@ public class EntityService : RepositoryService, IEntityService if (take == 0) { - totalRecords = CountChildren(parentId, childObjectType, filter); + totalRecords = CountChildren(parentId, childObjectType, filter: filter); return Enumerable.Empty(); } @@ -487,6 +487,12 @@ public class EntityService : RepositoryService, IEntityService return Enumerable.Empty(); } + if (take == 0) + { + totalRecords = CountChildren(parentId, objectType, true, filter); + return Enumerable.Empty(); + } + PaginationHelper.ConvertSkipTakeToPaging(skip, take, out var pageNumber, out var pageSize); IEnumerable children = GetPagedChildren( @@ -693,17 +699,18 @@ public class EntityService : RepositoryService, IEntityService } } - private int CountChildren(int id, UmbracoObjectTypes objectType, IQuery? filter = null) => - CountChildren(id, new HashSet() { objectType }, filter); + private int CountChildren(int id, UmbracoObjectTypes objectType, bool trashed = false, IQuery? filter = null) => + CountChildren(id, new HashSet() { objectType }, trashed, filter); private int CountChildren( int id, IEnumerable objectTypes, + bool trashed = false, IQuery? filter = null) { using (ScopeProvider.CreateCoreScope(autoComplete: true)) { - IQuery query = Query().Where(x => x.ParentId == id && x.Trashed == false); + IQuery query = Query().Where(x => x.ParentId == id && x.Trashed == trashed); var objectTypeGuids = objectTypes.Select(x => x.GetGuid()).ToHashSet(); return _entityRepository.CountByQuery(query, objectTypeGuids, filter); @@ -782,7 +789,7 @@ public class EntityService : RepositoryService, IEntityService if (take == 0) { - totalRecords = CountChildren(parentId, childObjectTypes, filter); + totalRecords = CountChildren(parentId, childObjectTypes, filter: filter); return Array.Empty(); }