diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs
index f69ab4867a..60a631e266 100644
--- a/src/Umbraco.Core/Services/ContentService.cs
+++ b/src/Umbraco.Core/Services/ContentService.cs
@@ -302,40 +302,16 @@ public class ContentService : RepositoryService, IContentService
#region Count
public int CountPublished(string? contentTypeAlias = null)
- {
- using (ICoreScope scope = ScopeProvider.CreateCoreScope(autoComplete: true))
- {
- scope.ReadLock(Constants.Locks.ContentTree);
- return _documentRepository.CountPublished(contentTypeAlias);
- }
- }
+ => QueryOperationService.CountPublished(contentTypeAlias);
public int Count(string? contentTypeAlias = null)
- {
- using (ICoreScope scope = ScopeProvider.CreateCoreScope(autoComplete: true))
- {
- scope.ReadLock(Constants.Locks.ContentTree);
- return _documentRepository.Count(contentTypeAlias);
- }
- }
+ => QueryOperationService.Count(contentTypeAlias);
public int CountChildren(int parentId, string? contentTypeAlias = null)
- {
- using (ICoreScope scope = ScopeProvider.CreateCoreScope(autoComplete: true))
- {
- scope.ReadLock(Constants.Locks.ContentTree);
- return _documentRepository.CountChildren(parentId, contentTypeAlias);
- }
- }
+ => QueryOperationService.CountChildren(parentId, contentTypeAlias);
public int CountDescendants(int parentId, string? contentTypeAlias = null)
- {
- using (ICoreScope scope = ScopeProvider.CreateCoreScope(autoComplete: true))
- {
- scope.ReadLock(Constants.Locks.ContentTree);
- return _documentRepository.CountDescendants(parentId, contentTypeAlias);
- }
- }
+ => QueryOperationService.CountDescendants(parentId, contentTypeAlias);
#endregion
diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceRefactoringTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceRefactoringTests.cs
index fb39a28951..4e996cd09a 100644
--- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceRefactoringTests.cs
+++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceRefactoringTests.cs
@@ -673,6 +673,81 @@ internal sealed class ContentServiceRefactoringTests : UmbracoIntegrationTestWit
#endregion
+ #region Phase 2 - Count Method Delegation Tests
+
+ ///
+ /// Phase 2 Test: Verifies Count() via facade returns same result as direct service call.
+ ///
+ [Test]
+ public void Count_ViaFacade_ReturnsEquivalentResultToDirectService()
+ {
+ // Arrange
+ var queryService = GetRequiredService();
+
+ // Act
+ var facadeCount = ContentService.Count();
+ var directCount = queryService.Count();
+
+ // Assert
+ Assert.That(facadeCount, Is.EqualTo(directCount));
+ }
+
+ ///
+ /// Phase 2 Test: Verifies CountPublished() via facade returns same result as direct service call.
+ ///
+ [Test]
+ public void CountPublished_ViaFacade_ReturnsEquivalentResultToDirectService()
+ {
+ // Arrange
+ var queryService = GetRequiredService();
+ ContentService.Publish(Textpage, new[] { "*" });
+
+ // Act
+ var facadeCount = ContentService.CountPublished();
+ var directCount = queryService.CountPublished();
+
+ // Assert
+ Assert.That(facadeCount, Is.EqualTo(directCount));
+ }
+
+ ///
+ /// Phase 2 Test: Verifies CountChildren() via facade returns same result as direct service call.
+ ///
+ [Test]
+ public void CountChildren_ViaFacade_ReturnsEquivalentResultToDirectService()
+ {
+ // Arrange
+ var queryService = GetRequiredService();
+ var parentId = Textpage.Id;
+
+ // Act
+ var facadeCount = ContentService.CountChildren(parentId);
+ var directCount = queryService.CountChildren(parentId);
+
+ // Assert
+ Assert.That(facadeCount, Is.EqualTo(directCount));
+ }
+
+ ///
+ /// Phase 2 Test: Verifies CountDescendants() via facade returns same result as direct service call.
+ ///
+ [Test]
+ public void CountDescendants_ViaFacade_ReturnsEquivalentResultToDirectService()
+ {
+ // Arrange
+ var queryService = GetRequiredService();
+ var parentId = Textpage.Id;
+
+ // Act
+ var facadeCount = ContentService.CountDescendants(parentId);
+ var directCount = queryService.CountDescendants(parentId);
+
+ // Assert
+ Assert.That(facadeCount, Is.EqualTo(directCount));
+ }
+
+ #endregion
+
///
/// Notification handler that tracks the order of notifications for test verification.
///