Browse Source

refactored identity role repository for filtering

pull/4044/head
Akın Sabri Çam 6 years ago
parent
commit
5359b0c5fb
  1. 1
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityRoleRepository.cs
  2. 4
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs
  3. 4
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityRoleRepository.cs

1
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityRoleRepository.cs

@ -18,6 +18,7 @@ namespace Volo.Abp.Identity
string sorting = null, string sorting = null,
int maxResultCount = int.MaxValue, int maxResultCount = int.MaxValue,
int skipCount = 0, int skipCount = 0,
string filter = null,
bool includeDetails = false, bool includeDetails = false,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
); );

4
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs

@ -32,11 +32,15 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
string sorting = null, string sorting = null,
int maxResultCount = int.MaxValue, int maxResultCount = int.MaxValue,
int skipCount = 0, int skipCount = 0,
string filter = null,
bool includeDetails = true, bool includeDetails = true,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await DbSet return await DbSet
.IncludeDetails(includeDetails) .IncludeDetails(includeDetails)
.WhereIf(filter != null,
x => x.Name.Contains(filter) ||
x.NormalizedName.Contains(filter))
.OrderBy(sorting ?? nameof(IdentityRole.Name)) .OrderBy(sorting ?? nameof(IdentityRole.Name))
.PageBy(skipCount, maxResultCount) .PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));

4
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityRoleRepository.cs

@ -31,10 +31,14 @@ namespace Volo.Abp.Identity.MongoDB
string sorting = null, string sorting = null,
int maxResultCount = int.MaxValue, int maxResultCount = int.MaxValue,
int skipCount = 0, int skipCount = 0,
string filter = null,
bool includeDetails = false, bool includeDetails = false,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await GetMongoQueryable() return await GetMongoQueryable()
.WhereIf(filter != null,
x => x.Name.Contains(filter) ||
x.NormalizedName.Contains(filter))
.OrderBy(sorting ?? nameof(IdentityRole.Name)) .OrderBy(sorting ?? nameof(IdentityRole.Name))
.As<IMongoQueryable<IdentityRole>>() .As<IMongoQueryable<IdentityRole>>()
.PageBy<IdentityRole, IMongoQueryable<IdentityRole>>(skipCount, maxResultCount) .PageBy<IdentityRole, IMongoQueryable<IdentityRole>>(skipCount, maxResultCount)

Loading…
Cancel
Save