diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityRoleRepository.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityRoleRepository.cs index f615de0933..8d32f8cb94 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityRoleRepository.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityRoleRepository.cs @@ -14,10 +14,6 @@ public interface IIdentityRoleRepository : IBasicRepository CancellationToken cancellationToken = default ); - Task> GetAllListWithUserCountAsync( - CancellationToken cancellationToken = default - ); - Task> GetListWithUserCountAsync( string sorting = null, int maxResultCount = int.MaxValue, diff --git a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs index 340ad688de..c902330b4e 100644 --- a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs +++ b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs @@ -28,23 +28,6 @@ public class EfCoreIdentityRoleRepository : EfCoreRepository r.NormalizedName == normalizedRoleName, GetCancellationToken(cancellationToken)); } - public async Task> GetAllListWithUserCountAsync(CancellationToken cancellationToken = default) - { - var roles = await GetListInternalAsync(cancellationToken: cancellationToken); - var roleIds = roles.Select(x => x.Id).ToList(); - var userCount = await (await GetDbContextAsync()).Set() - .Where(userRole => roleIds.Contains(userRole.RoleId)) - .GroupBy(userRole => userRole.RoleId) - .Select(x => new - { - RoleId = x.Key, - Count = x.Count() - }) - .ToListAsync(GetCancellationToken(cancellationToken)); - - return roles.Select(role => new RoleWithUserCount(role, userCount.FirstOrDefault(x => x.RoleId == role.Id)?.Count ?? 0)).ToList(); - } - public async Task> GetListWithUserCountAsync( string sorting = null, int maxResultCount = int.MaxValue, diff --git a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityRoleRepository.cs b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityRoleRepository.cs index 83a987ae16..3d0c1b65c0 100644 --- a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityRoleRepository.cs +++ b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityRoleRepository.cs @@ -28,24 +28,6 @@ public class MongoIdentityRoleRepository : MongoDbRepository r.NormalizedName == normalizedRoleName, GetCancellationToken(cancellationToken)); } - public async Task> GetAllListWithUserCountAsync(CancellationToken cancellationToken = default) - { - var roles = await GetListInternalAsync(cancellationToken : cancellationToken); - var roleIds = roles.Select(x => x.Id).ToList(); - var userCount = await (await GetMongoQueryableAsync(cancellationToken)) - .Where(user => user.Roles.Any(role => roleIds.Contains(role.RoleId))) - .SelectMany(user => user.Roles) - .GroupBy(userRole => userRole.RoleId) - .Select(x => new - { - RoleId = x.Key, - Count = x.Count() - }) - .ToListAsync(GetCancellationToken(cancellationToken)); - - return roles.Select(role => new RoleWithUserCount(role, userCount.FirstOrDefault(x => x.RoleId == role.Id)?.Count ?? 0)).ToList(); - } - public async Task> GetListWithUserCountAsync( string sorting = null, int maxResultCount = int.MaxValue, diff --git a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityRoleRepository_Tests.cs b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityRoleRepository_Tests.cs index 41dcc8e6ba..c34e9ad56c 100644 --- a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityRoleRepository_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityRoleRepository_Tests.cs @@ -68,9 +68,9 @@ public abstract class IdentityRoleRepository_Tests : AbpIdentity } [Fact] - public async Task GetAllListWithUserCountAsync() + public async Task GetListWithUserCountAsync() { - var roles = await RoleRepository.GetAllListWithUserCountAsync(); + var roles = await RoleRepository.GetListWithUserCountAsync(); roles.Count.ShouldBe(4); roles.ShouldContain(r => r.Role.Name == "admin" && r.UserCount == 2); @@ -78,13 +78,4 @@ public abstract class IdentityRoleRepository_Tests : AbpIdentity roles.ShouldContain(r => r.Role.Name == "supporter" && r.UserCount == 2); roles.ShouldContain(r => r.Role.Name == "manager" && r.UserCount == 1); } - - [Fact] - public async Task GetListWithUserCountAsync() - { - var roles = await RoleRepository.GetListWithUserCountAsync(filter: "admin"); - - roles.Count.ShouldBe(1); - roles.ShouldContain(r => r.Role.Name == "admin" && r.UserCount == 2); - } }