Browse Source

Merge pull request #6396 from abpframework/liangshiwei/patch-1

Add OrderBy top the first/firstordefault operator
pull/6406/head
maliming 6 years ago
committed by GitHub
parent
commit
a133314b2f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs
  2. 13
      modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs
  3. 1
      modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/EfCoreFeatureValueRepository.cs
  4. 1
      modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/MongoFeatureValueRepository.cs
  5. 2
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EFCoreIdentitySecurityLogRepository.cs
  6. 3
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityLinkUserRepository.cs
  7. 3
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs
  8. 6
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs
  9. 1
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreOrganizationUnitRepository.cs
  10. 3
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityLinkUserRepository.cs
  11. 6
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityRoleRepository.cs
  12. 2
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentitySecurityLogRepository.cs
  13. 10
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs
  14. 1
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoOrganizationUnitRepository.cs
  15. 4
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiScopes/ApiScopeRepository.cs
  16. 1
      modules/permission-management/src/Volo.Abp.PermissionManagement.EntityFrameworkCore/Volo/Abp/PermissionManagement/EntityFrameworkCore/EfCorePermissionGrantRepository.cs
  17. 1
      modules/permission-management/src/Volo.Abp.PermissionManagement.MongoDB/Volo/Abp/PermissionManagement/MongoDb/MongoPermissionGrantRepository.cs
  18. 1
      modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/EfCoreSettingRepository.cs
  19. 2
      modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/MongoSettingRepository.cs
  20. 10
      modules/users/src/Volo.Abp.Users.EntityFrameworkCore/Volo/Abp/Users/EntityFrameworkCore/EfCoreAbpUserRepositoryBase.cs
  21. 6
      modules/users/src/Volo.Abp.Users.MongoDB/Volo/Abp/Users/MongoDB/MongoUserRepositoryBase.cs

4
modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs

@ -136,7 +136,7 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore
return result.ToDictionary(element => element.Day.ClearTime(), element => element.avgExecutionTime); return result.ToDictionary(element => element.Day.ClearTime(), element => element.avgExecutionTime);
} }
public override IQueryable<AuditLog> WithDetails() public override IQueryable<AuditLog> WithDetails()
{ {
return GetQueryable().IncludeDetails(); return GetQueryable().IncludeDetails();
@ -147,8 +147,8 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore
var entityChange = await DbContext.Set<EntityChange>() var entityChange = await DbContext.Set<EntityChange>()
.AsNoTracking() .AsNoTracking()
.IncludeDetails() .IncludeDetails()
.OrderBy(x => x.Id)
.Where(x => x.Id == entityChangeId) .Where(x => x.Id == entityChangeId)
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(); .FirstOrDefaultAsync();
if (entityChange == null) if (entityChange == null)

13
modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs

@ -24,7 +24,7 @@ namespace Volo.Abp.AuditLogging.MongoDB
public virtual async Task<List<AuditLog>> GetListAsync( public virtual async Task<List<AuditLog>> GetListAsync(
string sorting = null, string sorting = null,
int maxResultCount = 50, int maxResultCount = 50,
int skipCount = 0, int skipCount = 0,
DateTime? startTime = null, DateTime? startTime = null,
DateTime? endTime = null, DateTime? endTime = null,
@ -145,9 +145,10 @@ namespace Volo.Abp.AuditLogging.MongoDB
{ {
var entityChange = (await GetMongoQueryable() var entityChange = (await GetMongoQueryable()
.Where(x => x.EntityChanges.Any(y => y.Id == entityChangeId)) .Where(x => x.EntityChanges.Any(y => y.Id == entityChangeId))
.OrderBy(x => x.Id)
.FirstAsync()).EntityChanges.FirstOrDefault(x => x.Id == entityChangeId); .FirstAsync()).EntityChanges.FirstOrDefault(x => x.Id == entityChangeId);
if (entityChange == null) if (entityChange == null)
{ {
throw new EntityNotFoundException(typeof(EntityChange)); throw new EntityNotFoundException(typeof(EntityChange));
@ -174,7 +175,7 @@ namespace Volo.Abp.AuditLogging.MongoDB
var auditLogs = await query.As<IMongoQueryable<EntityChange>>() var auditLogs = await query.As<IMongoQueryable<EntityChange>>()
.PageBy<EntityChange, IMongoQueryable<EntityChange>>(skipCount, maxResultCount) .PageBy<EntityChange, IMongoQueryable<EntityChange>>(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
return auditLogs.AsQueryable().OrderBy(sorting ?? "changeTime desc").ToList(); return auditLogs.AsQueryable().OrderBy(sorting ?? "changeTime desc").ToList();
} }
@ -188,7 +189,7 @@ namespace Volo.Abp.AuditLogging.MongoDB
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var query = GetEntityChangeListQuery(auditLogId, startTime, endTime, changeType, entityId, entityTypeFullName); var query = GetEntityChangeListQuery(auditLogId, startTime, endTime, changeType, entityId, entityTypeFullName);
var count = await query.As<IMongoQueryable<EntityChange>>().LongCountAsync(GetCancellationToken(cancellationToken)); var count = await query.As<IMongoQueryable<EntityChange>>().LongCountAsync(GetCancellationToken(cancellationToken));
return count; return count;
@ -216,7 +217,7 @@ namespace Volo.Abp.AuditLogging.MongoDB
.ToListAsync(); .ToListAsync();
var entityChanges = auditLogs.SelectMany(x => x.EntityChanges).ToList(); var entityChanges = auditLogs.SelectMany(x => x.EntityChanges).ToList();
entityChanges.RemoveAll(x => x.EntityId != entityId || x.EntityTypeFullName != entityTypeFullName); entityChanges.RemoveAll(x => x.EntityId != entityId || x.EntityTypeFullName != entityTypeFullName);
return entityChanges.Select(x => new EntityChangeWithUsername() return entityChanges.Select(x => new EntityChangeWithUsername()

1
modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/EfCoreFeatureValueRepository.cs

@ -18,6 +18,7 @@ namespace Volo.Abp.FeatureManagement.EntityFrameworkCore
public virtual async Task<FeatureValue> FindAsync(string name, string providerName, string providerKey) public virtual async Task<FeatureValue> FindAsync(string name, string providerName, string providerKey)
{ {
return await DbSet return await DbSet
.OrderBy(x => x.Id)
.FirstOrDefaultAsync( .FirstOrDefaultAsync(
s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey
); );

1
modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/MongoFeatureValueRepository.cs

@ -19,6 +19,7 @@ namespace Volo.Abp.FeatureManagement.MongoDB
public virtual async Task<FeatureValue> FindAsync(string name, string providerName, string providerKey) public virtual async Task<FeatureValue> FindAsync(string name, string providerName, string providerKey)
{ {
return await GetMongoQueryable() return await GetMongoQueryable()
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey); .FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey);
} }

2
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EFCoreIdentitySecurityLogRepository.cs

@ -80,7 +80,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
public async Task<IdentitySecurityLog> GetByUserIdAsync(Guid id, Guid userId, bool includeDetails = false, CancellationToken cancellationToken = default) public async Task<IdentitySecurityLog> GetByUserIdAsync(Guid id, Guid userId, bool includeDetails = false, CancellationToken cancellationToken = default)
{ {
return await DbSet.FirstOrDefaultAsync(x => x.Id == id && x.UserId == userId, GetCancellationToken(cancellationToken)); return await DbSet.OrderBy(x => x.Id).FirstOrDefaultAsync(x => x.Id == id && x.UserId == userId, GetCancellationToken(cancellationToken));
} }
protected virtual IQueryable<IdentitySecurityLog> GetListQuery( protected virtual IQueryable<IdentitySecurityLog> GetListQuery(

3
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityLinkUserRepository.cs

@ -20,7 +20,8 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
public async Task<IdentityLinkUser> FindAsync(IdentityLinkUserInfo sourceLinkUserInfo, IdentityLinkUserInfo targetLinkUserInfo, CancellationToken cancellationToken = default) public async Task<IdentityLinkUser> FindAsync(IdentityLinkUserInfo sourceLinkUserInfo, IdentityLinkUserInfo targetLinkUserInfo, CancellationToken cancellationToken = default)
{ {
return await DbSet.FirstOrDefaultAsync(x => return await DbSet
.OrderBy(x => x.Id).FirstOrDefaultAsync(x =>
x.SourceUserId == sourceLinkUserInfo.UserId && x.SourceTenantId == sourceLinkUserInfo.TenantId && x.SourceUserId == sourceLinkUserInfo.UserId && x.SourceTenantId == sourceLinkUserInfo.TenantId &&
x.TargetUserId == targetLinkUserInfo.UserId && x.TargetTenantId == targetLinkUserInfo.TenantId || x.TargetUserId == targetLinkUserInfo.UserId && x.TargetTenantId == targetLinkUserInfo.TenantId ||
x.TargetUserId == sourceLinkUserInfo.UserId && x.TargetTenantId == sourceLinkUserInfo.TenantId && x.TargetUserId == sourceLinkUserInfo.UserId && x.TargetTenantId == sourceLinkUserInfo.TenantId &&

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

@ -24,6 +24,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
{ {
return await DbSet return await DbSet
.IncludeDetails(includeDetails) .IncludeDetails(includeDetails)
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(r => r.NormalizedName == normalizedRoleName, GetCancellationToken(cancellationToken)); .FirstOrDefaultAsync(r => r.NormalizedName == normalizedRoleName, GetCancellationToken(cancellationToken));
} }
@ -76,4 +77,4 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
return GetQueryable().IncludeDetails(); return GetQueryable().IncludeDetails();
} }
} }
} }

6
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs

@ -26,7 +26,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
{ {
return await DbSet return await DbSet
.IncludeDetails(includeDetails) .IncludeDetails(includeDetails)
.OrderBy(x => x.NormalizedUserName) .OrderBy(x => x.Id)
.FirstOrDefaultAsync( .FirstOrDefaultAsync(
u => u.NormalizedUserName == normalizedUserName, u => u.NormalizedUserName == normalizedUserName,
GetCancellationToken(cancellationToken) GetCancellationToken(cancellationToken)
@ -80,6 +80,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
return await DbSet return await DbSet
.IncludeDetails(includeDetails) .IncludeDetails(includeDetails)
.Where(u => u.Logins.Any(login => login.LoginProvider == loginProvider && login.ProviderKey == providerKey)) .Where(u => u.Logins.Any(login => login.LoginProvider == loginProvider && login.ProviderKey == providerKey))
.OrderBy(x=>x.Id)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); .FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
} }
@ -90,7 +91,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
{ {
return await DbSet return await DbSet
.IncludeDetails(includeDetails) .IncludeDetails(includeDetails)
.OrderBy(x => x.NormalizedEmail) .OrderBy(x => x.Id)
.FirstOrDefaultAsync(u => u.NormalizedEmail == normalizedEmail, GetCancellationToken(cancellationToken)); .FirstOrDefaultAsync(u => u.NormalizedEmail == normalizedEmail, GetCancellationToken(cancellationToken));
} }
@ -112,6 +113,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
{ {
var role = await DbContext.Roles var role = await DbContext.Roles
.Where(x => x.NormalizedName == normalizedRoleName) .Where(x => x.NormalizedName == normalizedRoleName)
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); .FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
if (role == null) if (role == null)

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

@ -75,6 +75,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
{ {
return await DbSet return await DbSet
.IncludeDetails(includeDetails) .IncludeDetails(includeDetails)
.OrderBy(x => x.Id)
.FirstOrDefaultAsync( .FirstOrDefaultAsync(
ou => ou.DisplayName == displayName, ou => ou.DisplayName == displayName,
GetCancellationToken(cancellationToken) GetCancellationToken(cancellationToken)

3
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityLinkUserRepository.cs

@ -19,7 +19,8 @@ namespace Volo.Abp.Identity.MongoDB
public async Task<IdentityLinkUser> FindAsync(IdentityLinkUserInfo sourceLinkUserInfo, IdentityLinkUserInfo targetLinkUserInfo, CancellationToken cancellationToken = default) public async Task<IdentityLinkUser> FindAsync(IdentityLinkUserInfo sourceLinkUserInfo, IdentityLinkUserInfo targetLinkUserInfo, CancellationToken cancellationToken = default)
{ {
return await GetMongoQueryable().FirstOrDefaultAsync(x => return await GetMongoQueryable()
.OrderBy(x => x.Id).FirstOrDefaultAsync(x =>
x.SourceUserId == sourceLinkUserInfo.UserId && x.SourceTenantId == sourceLinkUserInfo.TenantId && x.SourceUserId == sourceLinkUserInfo.UserId && x.SourceTenantId == sourceLinkUserInfo.TenantId &&
x.TargetUserId == targetLinkUserInfo.UserId && x.TargetTenantId == targetLinkUserInfo.TenantId || x.TargetUserId == targetLinkUserInfo.UserId && x.TargetTenantId == targetLinkUserInfo.TenantId ||
x.TargetUserId == sourceLinkUserInfo.UserId && x.TargetTenantId == sourceLinkUserInfo.TenantId && x.TargetUserId == sourceLinkUserInfo.UserId && x.TargetTenantId == sourceLinkUserInfo.TenantId &&

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

@ -23,7 +23,9 @@ namespace Volo.Abp.Identity.MongoDB
bool includeDetails = true, bool includeDetails = true,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await GetMongoQueryable().FirstOrDefaultAsync(r => r.NormalizedName == normalizedRoleName, GetCancellationToken(cancellationToken)); return await GetMongoQueryable()
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(r => r.NormalizedName == normalizedRoleName, GetCancellationToken(cancellationToken));
} }
public async Task<List<IdentityRole>> GetListAsync( public async Task<List<IdentityRole>> GetListAsync(
@ -72,4 +74,4 @@ namespace Volo.Abp.Identity.MongoDB
.LongCountAsync(GetCancellationToken(cancellationToken)); .LongCountAsync(GetCancellationToken(cancellationToken));
} }
} }
} }

2
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentitySecurityLogRepository.cs

@ -85,7 +85,7 @@ namespace Volo.Abp.Identity.MongoDB
public async Task<IdentitySecurityLog> GetByUserIdAsync(Guid id, Guid userId, bool includeDetails = false, public async Task<IdentitySecurityLog> GetByUserIdAsync(Guid id, Guid userId, bool includeDetails = false,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await GetMongoQueryable().FirstOrDefaultAsync(x => x.Id == id && x.UserId == userId, return await GetMongoQueryable().OrderBy(x => x.Id).FirstOrDefaultAsync(x => x.Id == id && x.UserId == userId,
GetCancellationToken(cancellationToken)); GetCancellationToken(cancellationToken));
} }

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

@ -25,6 +25,7 @@ namespace Volo.Abp.Identity.MongoDB
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await GetMongoQueryable() return await GetMongoQueryable()
.OrderBy(x => x.Id)
.FirstOrDefaultAsync( .FirstOrDefaultAsync(
u => u.NormalizedUserName == normalizedUserName, u => u.NormalizedUserName == normalizedUserName,
GetCancellationToken(cancellationToken) GetCancellationToken(cancellationToken)
@ -81,6 +82,7 @@ namespace Volo.Abp.Identity.MongoDB
{ {
return await GetMongoQueryable() return await GetMongoQueryable()
.Where(u => u.Logins.Any(login => login.LoginProvider == loginProvider && login.ProviderKey == providerKey)) .Where(u => u.Logins.Any(login => login.LoginProvider == loginProvider && login.ProviderKey == providerKey))
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); .FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
} }
@ -89,7 +91,8 @@ namespace Volo.Abp.Identity.MongoDB
bool includeDetails = true, bool includeDetails = true,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await GetMongoQueryable().FirstOrDefaultAsync(u => u.NormalizedEmail == normalizedEmail, GetCancellationToken(cancellationToken)); return await GetMongoQueryable()
.OrderBy(x => x.Id).FirstOrDefaultAsync(u => u.NormalizedEmail == normalizedEmail, GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<IdentityUser>> GetListByClaimAsync( public virtual async Task<List<IdentityUser>> GetListByClaimAsync(
@ -107,7 +110,10 @@ namespace Volo.Abp.Identity.MongoDB
bool includeDetails = false, bool includeDetails = false,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var role = await DbContext.Roles.AsQueryable().Where(x => x.NormalizedName == normalizedRoleName).FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); var role = await DbContext.Roles.AsQueryable()
.Where(x => x.NormalizedName == normalizedRoleName)
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
if (role == null) if (role == null)
{ {

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

@ -76,6 +76,7 @@ namespace Volo.Abp.Identity.MongoDB
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await GetMongoQueryable() return await GetMongoQueryable()
.OrderBy(x => x.Id)
.FirstOrDefaultAsync( .FirstOrDefaultAsync(
ou => ou.DisplayName == displayName, ou => ou.DisplayName == displayName,
GetCancellationToken(cancellationToken) GetCancellationToken(cancellationToken)

4
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/ApiScopes/ApiScopeRepository.cs

@ -20,7 +20,9 @@ namespace Volo.Abp.IdentityServer.ApiScopes
public async Task<ApiScope> GetByNameAsync(string scopeName, bool includeDetails = true, CancellationToken cancellationToken = default) public async Task<ApiScope> GetByNameAsync(string scopeName, bool includeDetails = true, CancellationToken cancellationToken = default)
{ {
return await DbSet.FirstOrDefaultAsync(x => x.Name == scopeName, GetCancellationToken(cancellationToken)); return await DbSet
.OrderBy(x=>x.Id)
.FirstOrDefaultAsync(x => x.Name == scopeName, GetCancellationToken(cancellationToken));
} }
public async Task<List<ApiScope>> GetListByNameAsync(string[] scopeNames, bool includeDetails = false, public async Task<List<ApiScope>> GetListByNameAsync(string[] scopeNames, bool includeDetails = false,

1
modules/permission-management/src/Volo.Abp.PermissionManagement.EntityFrameworkCore/Volo/Abp/PermissionManagement/EntityFrameworkCore/EfCorePermissionGrantRepository.cs

@ -25,6 +25,7 @@ namespace Volo.Abp.PermissionManagement.EntityFrameworkCore
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await DbSet return await DbSet
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(s => .FirstOrDefaultAsync(s =>
s.Name == name && s.Name == name &&
s.ProviderName == providerName && s.ProviderName == providerName &&

1
modules/permission-management/src/Volo.Abp.PermissionManagement.MongoDB/Volo/Abp/PermissionManagement/MongoDb/MongoPermissionGrantRepository.cs

@ -25,6 +25,7 @@ namespace Volo.Abp.PermissionManagement.MongoDB
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await GetMongoQueryable() return await GetMongoQueryable()
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(s => .FirstOrDefaultAsync(s =>
s.Name == name && s.Name == name &&
s.ProviderName == providerName && s.ProviderName == providerName &&

1
modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/EfCoreSettingRepository.cs

@ -18,6 +18,7 @@ namespace Volo.Abp.SettingManagement.EntityFrameworkCore
public virtual async Task<Setting> FindAsync(string name, string providerName, string providerKey) public virtual async Task<Setting> FindAsync(string name, string providerName, string providerKey)
{ {
return await DbSet return await DbSet
.OrderBy(x => x.Id)
.FirstOrDefaultAsync( .FirstOrDefaultAsync(
s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey
); );

2
modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/MongoSettingRepository.cs

@ -19,7 +19,7 @@ namespace Volo.Abp.SettingManagement.MongoDB
public virtual async Task<Setting> FindAsync(string name, string providerName, string providerKey) public virtual async Task<Setting> FindAsync(string name, string providerName, string providerKey)
{ {
return await GetMongoQueryable().FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey); return await GetMongoQueryable().OrderBy(x => x.Id).FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey);
} }
public virtual async Task<List<Setting>> GetListAsync(string providerName, string providerKey) public virtual async Task<List<Setting>> GetListAsync(string providerName, string providerKey)

10
modules/users/src/Volo.Abp.Users.EntityFrameworkCore/Volo/Abp/Users/EntityFrameworkCore/EfCoreAbpUserRepositoryBase.cs

@ -22,7 +22,7 @@ namespace Volo.Abp.Users.EntityFrameworkCore
public async Task<TUser> FindByUserNameAsync(string userName, CancellationToken cancellationToken = default) public async Task<TUser> FindByUserNameAsync(string userName, CancellationToken cancellationToken = default)
{ {
return await this.FirstOrDefaultAsync(u => u.UserName == userName, GetCancellationToken(cancellationToken)); return await this.OrderBy(x => x.Id).FirstOrDefaultAsync(u => u.UserName == userName, GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<TUser>> GetListAsync(IEnumerable<Guid> ids, CancellationToken cancellationToken = default) public virtual async Task<List<TUser>> GetListAsync(IEnumerable<Guid> ids, CancellationToken cancellationToken = default)
@ -31,8 +31,8 @@ namespace Volo.Abp.Users.EntityFrameworkCore
} }
public async Task<List<TUser>> SearchAsync( public async Task<List<TUser>> SearchAsync(
string sorting = null, string sorting = null,
int maxResultCount = int.MaxValue, int maxResultCount = int.MaxValue,
int skipCount = 0, int skipCount = 0,
string filter = null, string filter = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
@ -52,7 +52,7 @@ namespace Volo.Abp.Users.EntityFrameworkCore
} }
public async Task<long> GetCountAsync( public async Task<long> GetCountAsync(
string filter = null, string filter = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return await DbSet return await DbSet
@ -67,4 +67,4 @@ namespace Volo.Abp.Users.EntityFrameworkCore
.LongCountAsync(GetCancellationToken(cancellationToken)); .LongCountAsync(GetCancellationToken(cancellationToken));
} }
} }
} }

6
modules/users/src/Volo.Abp.Users.MongoDB/Volo/Abp/Users/MongoDB/MongoUserRepositoryBase.cs

@ -23,7 +23,7 @@ namespace Volo.Abp.Users.MongoDB
public virtual async Task<TUser> FindByUserNameAsync(string userName, CancellationToken cancellationToken = default) public virtual async Task<TUser> FindByUserNameAsync(string userName, CancellationToken cancellationToken = default)
{ {
return await GetMongoQueryable().FirstOrDefaultAsync(u => u.UserName == userName, GetCancellationToken(cancellationToken)); return await GetMongoQueryable().OrderBy(x => x.Id).FirstOrDefaultAsync(u => u.UserName == userName, GetCancellationToken(cancellationToken));
} }
public virtual async Task<List<TUser>> GetListAsync(IEnumerable<Guid> ids, CancellationToken cancellationToken = default) public virtual async Task<List<TUser>> GetListAsync(IEnumerable<Guid> ids, CancellationToken cancellationToken = default)
@ -32,7 +32,7 @@ namespace Volo.Abp.Users.MongoDB
} }
public async Task<List<TUser>> SearchAsync( public async Task<List<TUser>> SearchAsync(
string sorting = null, string sorting = null,
int maxResultCount = int.MaxValue, int maxResultCount = int.MaxValue,
int skipCount = 0, int skipCount = 0,
string filter = null, string filter = null,
@ -67,4 +67,4 @@ namespace Volo.Abp.Users.MongoDB
.LongCountAsync(GetCancellationToken(cancellationToken)); .LongCountAsync(GetCancellationToken(cancellationToken));
} }
} }
} }

Loading…
Cancel
Save