Check NullOrEmpty for sortings instead of null coalescing in Identity

pull/8178/head
enisn 5 years ago
parent 93deac77f1
commit 77f7fc64d9

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

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

Loading…
Cancel
Save