Browse Source

Check NullOrEmpty for sortings instead of null coalescing in Identity

pull/8178/head
enisn 6 years ago
parent
commit
77f7fc64d9
  1. 10
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreOrganizationUnitRepository.cs
  2. 10
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoOrganizationUnitRepository.cs

10
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreOrganizationUnitRepository.cs

@ -53,7 +53,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
{ {
return await (await GetDbSetAsync()) return await (await GetDbSetAsync())
.IncludeDetails(includeDetails) .IncludeDetails(includeDetails)
.OrderBy(sorting ?? nameof(OrganizationUnit.DisplayName)) .OrderBy(sorting.IsNullOrEmpty() ? nameof(OrganizationUnit.DisplayName) : sorting)
.PageBy(skipCount, maxResultCount) .PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
@ -99,7 +99,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
select role; select role;
query = query query = query
.OrderBy(sorting ?? nameof(IdentityRole.Name)) .OrderBy(sorting.IsNullOrEmpty() ? nameof(IdentityRole.Name) : sorting)
.PageBy(skipCount, maxResultCount); .PageBy(skipCount, maxResultCount);
return await query.ToListAsync(GetCancellationToken(cancellationToken)); return await query.ToListAsync(GetCancellationToken(cancellationToken));
@ -135,7 +135,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
.Where(r => !roleIds.Contains(r.Id)) .Where(r => !roleIds.Contains(r.Id))
.IncludeDetails(includeDetails) .IncludeDetails(includeDetails)
.WhereIf(!filter.IsNullOrWhiteSpace(), r => r.Name.Contains(filter)) .WhereIf(!filter.IsNullOrWhiteSpace(), r => r.Name.Contains(filter))
.OrderBy(sorting ?? nameof(IdentityRole.Name)) .OrderBy(sorting.IsNullOrEmpty() ? nameof(IdentityRole.Name) : sorting)
.PageBy(skipCount, maxResultCount) .PageBy(skipCount, maxResultCount)
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
} }
@ -165,7 +165,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
{ {
var query = await CreateGetMembersFilteredQueryAsync(organizationUnit, filter); var query = await CreateGetMembersFilteredQueryAsync(organizationUnit, filter);
return await query.IncludeDetails(includeDetails).OrderBy(sorting ?? nameof(IdentityUser.UserName)) return await query.IncludeDetails(includeDetails).OrderBy(sorting.IsNullOrEmpty() ? nameof(IdentityUser.UserName) : sorting)
.PageBy(skipCount, maxResultCount) .PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
@ -209,7 +209,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
return await query return await query
.IncludeDetails(includeDetails) .IncludeDetails(includeDetails)
.OrderBy(sorting ?? nameof(IdentityUser.Name)) .OrderBy(sorting.IsNullOrEmpty() ? nameof(IdentityUser.Name) : sorting)
.PageBy(skipCount, maxResultCount) .PageBy(skipCount, maxResultCount)
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
} }

10
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoOrganizationUnitRepository.cs

@ -61,7 +61,7 @@ namespace Volo.Abp.Identity.MongoDB
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await (await GetMongoQueryableAsync(cancellationToken)) return await (await GetMongoQueryableAsync(cancellationToken))
.OrderBy(sorting ?? nameof(OrganizationUnit.DisplayName)) .OrderBy(sorting.IsNullOrEmpty() ? nameof(OrganizationUnit.DisplayName) : sorting)
.As<IMongoQueryable<OrganizationUnit>>() .As<IMongoQueryable<OrganizationUnit>>()
.PageBy<OrganizationUnit, IMongoQueryable<OrganizationUnit>>(skipCount, maxResultCount) .PageBy<OrganizationUnit, IMongoQueryable<OrganizationUnit>>(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
@ -93,7 +93,7 @@ namespace Volo.Abp.Identity.MongoDB
return await ApplyDataFilters<IMongoQueryable<IdentityRole>, IdentityRole>( return await ApplyDataFilters<IMongoQueryable<IdentityRole>, IdentityRole>(
dbContext.Roles.AsQueryable().Where(r => roleIds.Contains(r.Id)) dbContext.Roles.AsQueryable().Where(r => roleIds.Contains(r.Id))
) )
.OrderBy(sorting ?? nameof(IdentityRole.Name)) .OrderBy(sorting.IsNullOrEmpty() ? nameof(IdentityRole.Name) : sorting)
.As<IMongoQueryable<IdentityRole>>() .As<IMongoQueryable<IdentityRole>>()
.PageBy<IdentityRole, IMongoQueryable<IdentityRole>>(skipCount, maxResultCount) .PageBy<IdentityRole, IMongoQueryable<IdentityRole>>(skipCount, maxResultCount)
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
@ -126,7 +126,7 @@ namespace Volo.Abp.Identity.MongoDB
return await ApplyDataFilters<IMongoQueryable<IdentityRole>, IdentityRole>(dbContext.Roles.AsQueryable()) return await ApplyDataFilters<IMongoQueryable<IdentityRole>, IdentityRole>(dbContext.Roles.AsQueryable())
.Where(r => !roleIds.Contains(r.Id)) .Where(r => !roleIds.Contains(r.Id))
.WhereIf(!filter.IsNullOrWhiteSpace(), r => r.Name.Contains(filter)) .WhereIf(!filter.IsNullOrWhiteSpace(), r => r.Name.Contains(filter))
.OrderBy(sorting ?? nameof(IdentityRole.Name)) .OrderBy(sorting.IsNullOrEmpty() ? nameof(IdentityRole.Name) : sorting)
.As<IMongoQueryable<IdentityRole>>() .As<IMongoQueryable<IdentityRole>>()
.PageBy<IdentityRole, IMongoQueryable<IdentityRole>>(skipCount, maxResultCount) .PageBy<IdentityRole, IMongoQueryable<IdentityRole>>(skipCount, maxResultCount)
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
@ -158,7 +158,7 @@ namespace Volo.Abp.Identity.MongoDB
cancellationToken = GetCancellationToken(cancellationToken); cancellationToken = GetCancellationToken(cancellationToken);
var query = await CreateGetMembersFilteredQueryAsync(organizationUnit, filter, cancellationToken); var query = await CreateGetMembersFilteredQueryAsync(organizationUnit, filter, cancellationToken);
return await query return await query
.OrderBy(sorting ?? nameof(IdentityUser.UserName)) .OrderBy(sorting.IsNullOrEmpty() ? nameof(IdentityUser.UserName) : sorting)
.As<IMongoQueryable<IdentityUser>>() .As<IMongoQueryable<IdentityUser>>()
.PageBy<IdentityUser, IMongoQueryable<IdentityUser>>(skipCount, maxResultCount) .PageBy<IdentityUser, IMongoQueryable<IdentityUser>>(skipCount, maxResultCount)
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
@ -193,7 +193,7 @@ namespace Volo.Abp.Identity.MongoDB
u.Email.Contains(filter) || u.Email.Contains(filter) ||
(u.PhoneNumber != null && u.PhoneNumber.Contains(filter)) (u.PhoneNumber != null && u.PhoneNumber.Contains(filter))
) )
.OrderBy(sorting ?? nameof(IdentityUser.UserName)) .OrderBy(sorting.IsNullOrEmpty() ? nameof(IdentityUser.UserName) : sorting)
.As<IMongoQueryable<IdentityUser>>() .As<IMongoQueryable<IdentityUser>>()
.PageBy<IdentityUser, IMongoQueryable<IdentityUser>>(skipCount, maxResultCount) .PageBy<IdentityUser, IMongoQueryable<IdentityUser>>(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));

Loading…
Cancel
Save