Apply async changes for EF Core repos.

pull/6809/head
Halil İbrahim Kalkan 5 years ago
parent c2c25a091a
commit 06889783f8

@ -17,7 +17,7 @@ namespace Volo.Abp.FeatureManagement.EntityFrameworkCore
public virtual async Task<FeatureValue> FindAsync(string name, string providerName, string providerKey)
{
return await DbSet
return await (await GetDbSetAsync())
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(
s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey
@ -26,7 +26,7 @@ namespace Volo.Abp.FeatureManagement.EntityFrameworkCore
public async Task<List<FeatureValue>> FindAllAsync(string name, string providerName, string providerKey)
{
return await DbSet
return await (await GetDbSetAsync())
.Where(
s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey
).ToListAsync();
@ -34,7 +34,7 @@ namespace Volo.Abp.FeatureManagement.EntityFrameworkCore
public virtual async Task<List<FeatureValue>> GetListAsync(string providerName, string providerKey)
{
return await DbSet
return await (await GetDbSetAsync())
.Where(
s => s.ProviderName == providerName && s.ProviderKey == providerKey
).ToListAsync();

@ -18,20 +18,20 @@ namespace Volo.Abp.FeatureManagement.MongoDB
public virtual async Task<FeatureValue> FindAsync(string name, string providerName, string providerKey)
{
return await GetMongoQueryable()
return await (await GetMongoQueryableAsync())
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey);
}
public async Task<List<FeatureValue>> FindAllAsync(string name, string providerName, string providerKey)
{
return await GetMongoQueryable()
return await (await GetMongoQueryableAsync())
.Where(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey).ToListAsync();
}
public virtual async Task<List<FeatureValue>> GetListAsync(string providerName, string providerKey)
{
return await GetMongoQueryable()
return await (await GetMongoQueryableAsync())
.Where(s => s.ProviderName == providerName && s.ProviderKey == providerKey)
.ToListAsync();
}

@ -20,7 +20,7 @@ namespace Volo.Abp.IdentityServer.ApiResources
public async Task<ApiResource> FindByNameAsync(string apiResourceName, bool includeDetails = true, CancellationToken cancellationToken = default)
{
var query = from apiResource in DbSet.IncludeDetails(includeDetails)
var query = from apiResource in (await GetDbSetAsync()).IncludeDetails(includeDetails)
where apiResource.Name == apiResourceName
orderby apiResource.Id
select apiResource;
@ -31,7 +31,7 @@ namespace Volo.Abp.IdentityServer.ApiResources
public async Task<List<ApiResource>> FindByNameAsync(string[] apiResourceNames, bool includeDetails = true,
CancellationToken cancellationToken = default)
{
var query = from apiResource in DbSet.IncludeDetails(includeDetails)
var query = from apiResource in (await GetDbSetAsync()).IncludeDetails(includeDetails)
where apiResourceNames.Contains(apiResource.Name)
orderby apiResource.Name
select apiResource;
@ -44,7 +44,7 @@ namespace Volo.Abp.IdentityServer.ApiResources
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
var query = from api in DbSet.IncludeDetails(includeDetails)
var query = from api in (await GetDbSetAsync()).IncludeDetails(includeDetails)
where api.Scopes.Any(x => scopeNames.Contains(x.Scope))
select api;
@ -58,7 +58,7 @@ namespace Volo.Abp.IdentityServer.ApiResources
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await DbSet
return await (await GetDbSetAsync())
.IncludeDetails(includeDetails)
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Name.Contains(filter) ||
x.Description.Contains(filter) ||
@ -70,41 +70,49 @@ namespace Volo.Abp.IdentityServer.ApiResources
public virtual async Task<bool> CheckNameExistAsync(string name, Guid? expectedId = null, CancellationToken cancellationToken = default)
{
return await DbSet.AnyAsync(ar => ar.Id != expectedId && ar.Name == name, GetCancellationToken(cancellationToken));
return await (await GetDbSetAsync()).AnyAsync(ar => ar.Id != expectedId && ar.Name == name, GetCancellationToken(cancellationToken));
}
public async override Task DeleteAsync(Guid id, bool autoSave = false, CancellationToken cancellationToken = default)
{
var resourceClaims = DbContext.Set<ApiResourceClaim>().Where(sc => sc.ApiResourceId == id);
var dbContext = await GetDbContextAsync();
var resourceClaims = dbContext.Set<ApiResourceClaim>().Where(sc => sc.ApiResourceId == id);
foreach (var scopeClaim in resourceClaims)
{
DbContext.Set<ApiResourceClaim>().Remove(scopeClaim);
dbContext.Set<ApiResourceClaim>().Remove(scopeClaim);
}
var resourceScopes = DbContext.Set<ApiResourceScope>().Where(s => s.ApiResourceId == id);
var resourceScopes = dbContext.Set<ApiResourceScope>().Where(s => s.ApiResourceId == id);
foreach (var scope in resourceScopes)
{
DbContext.Set<ApiResourceScope>().Remove(scope);
dbContext.Set<ApiResourceScope>().Remove(scope);
}
var resourceSecrets = DbContext.Set<ApiResourceSecret>().Where(s => s.ApiResourceId == id);
var resourceSecrets = dbContext.Set<ApiResourceSecret>().Where(s => s.ApiResourceId == id);
foreach (var secret in resourceSecrets)
{
DbContext.Set<ApiResourceSecret>().Remove(secret);
dbContext.Set<ApiResourceSecret>().Remove(secret);
}
var apiResourceProperties = DbContext.Set<ApiResourceProperty>().Where(s => s.ApiResourceId == id);
var apiResourceProperties = dbContext.Set<ApiResourceProperty>().Where(s => s.ApiResourceId == id);
foreach (var property in apiResourceProperties)
{
DbContext.Set<ApiResourceProperty>().Remove(property);
dbContext.Set<ApiResourceProperty>().Remove(property);
}
await base.DeleteAsync(id, autoSave, cancellationToken);
}
[Obsolete("Use WithDetailsAsync method.")]
public override IQueryable<ApiResource> WithDetails()
{
return GetQueryable().IncludeDetails();
}
public override async Task<IQueryable<ApiResource>> WithDetailsAsync()
{
return (await GetQueryableAsync()).IncludeDetails();
}
}
}

@ -20,7 +20,7 @@ namespace Volo.Abp.IdentityServer.ApiScopes
public async Task<ApiScope> GetByNameAsync(string scopeName, bool includeDetails = true, CancellationToken cancellationToken = default)
{
return await DbSet
return await (await GetDbSetAsync())
.OrderBy(x=>x.Id)
.FirstOrDefaultAsync(x => x.Name == scopeName, GetCancellationToken(cancellationToken));
}
@ -28,7 +28,7 @@ namespace Volo.Abp.IdentityServer.ApiScopes
public async Task<List<ApiScope>> GetListByNameAsync(string[] scopeNames, bool includeDetails = false,
CancellationToken cancellationToken = default)
{
var query = from scope in DbSet.IncludeDetails(includeDetails)
var query = from scope in (await GetDbSetAsync()).IncludeDetails(includeDetails)
where scopeNames.Contains(scope.Name)
orderby scope.Id
select scope;
@ -38,7 +38,7 @@ namespace Volo.Abp.IdentityServer.ApiScopes
public async Task<List<ApiScope>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null, bool includeDetails = false, CancellationToken cancellationToken = default)
{
return await DbSet
return await (await GetDbSetAsync())
.IncludeDetails(includeDetails)
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Name.Contains(filter) ||
x.Description.Contains(filter) ||
@ -50,29 +50,36 @@ namespace Volo.Abp.IdentityServer.ApiScopes
public async Task<bool> CheckNameExistAsync(string name, Guid? expectedId = null, CancellationToken cancellationToken = default)
{
return await DbSet.AnyAsync(x => x.Id != expectedId && x.Name == name, GetCancellationToken(cancellationToken));
return await (await GetDbSetAsync()).AnyAsync(x => x.Id != expectedId && x.Name == name, GetCancellationToken(cancellationToken));
}
public async override Task DeleteAsync(Guid id, bool autoSave = false, CancellationToken cancellationToken = new CancellationToken())
public override async Task DeleteAsync(Guid id, bool autoSave = false, CancellationToken cancellationToken = new CancellationToken())
{
var scopeClaims = DbContext.Set<ApiScopeClaim>().Where(sc => sc.ApiScopeId == id);
var dbContext = await GetDbContextAsync();
var scopeClaims = dbContext.Set<ApiScopeClaim>().Where(sc => sc.ApiScopeId == id);
foreach (var claim in scopeClaims)
{
DbContext.Set<ApiScopeClaim>().Remove(claim);
dbContext.Set<ApiScopeClaim>().Remove(claim);
}
var scopeProperties = DbContext.Set<ApiScopeProperty>().Where(s => s.ApiScopeId == id);
var scopeProperties = dbContext.Set<ApiScopeProperty>().Where(s => s.ApiScopeId == id);
foreach (var property in scopeProperties)
{
DbContext.Set<ApiScopeProperty>().Remove(property);
dbContext.Set<ApiScopeProperty>().Remove(property);
}
await base.DeleteAsync(id, autoSave, cancellationToken);
}
[Obsolete("Use WithDetailsAsync method.")]
public override IQueryable<ApiScope> WithDetails()
{
return GetQueryable().IncludeDetails();
}
public override async Task<IQueryable<ApiScope>> WithDetailsAsync()
{
return (await GetQueryableAsync()).IncludeDetails();
}
}
}

@ -23,7 +23,7 @@ namespace Volo.Abp.IdentityServer.Clients
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await DbSet
return await (await GetDbSetAsync())
.IncludeDetails(includeDetails)
.OrderBy(x => x.ClientId)
.FirstOrDefaultAsync(x => x.ClientId == clientId, GetCancellationToken(cancellationToken));
@ -33,7 +33,7 @@ namespace Volo.Abp.IdentityServer.Clients
string sorting, int skipCount, int maxResultCount, string filter, bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await DbSet
return await (await GetDbSetAsync())
.IncludeDetails(includeDetails)
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.ClientId.Contains(filter))
.OrderBy(sorting ?? nameof(Client.ClientName) + " desc")
@ -43,7 +43,7 @@ namespace Volo.Abp.IdentityServer.Clients
public virtual async Task<List<string>> GetAllDistinctAllowedCorsOriginsAsync(CancellationToken cancellationToken = default)
{
return await DbContext.ClientCorsOrigins
return await (await GetDbContextAsync()).ClientCorsOrigins
.Select(x => x.Origin)
.Distinct()
.ToListAsync(GetCancellationToken(cancellationToken));
@ -51,62 +51,70 @@ namespace Volo.Abp.IdentityServer.Clients
public virtual async Task<bool> CheckClientIdExistAsync(string clientId, Guid? expectedId = null, CancellationToken cancellationToken = default)
{
return await DbSet.AnyAsync(c => c.Id != expectedId && c.ClientId == clientId, cancellationToken: cancellationToken);
return await (await GetDbSetAsync()).AnyAsync(c => c.Id != expectedId && c.ClientId == clientId, cancellationToken: cancellationToken);
}
public async override Task DeleteAsync(Guid id, bool autoSave = false, CancellationToken cancellationToken = default)
{
foreach (var clientGrantType in DbContext.Set<ClientGrantType>().Where(x => x.ClientId == id))
var dbContext = await GetDbContextAsync();
foreach (var clientGrantType in dbContext.Set<ClientGrantType>().Where(x => x.ClientId == id))
{
DbContext.Set<ClientGrantType>().Remove(clientGrantType);
dbContext.Set<ClientGrantType>().Remove(clientGrantType);
}
foreach (var clientRedirectUri in DbContext.Set<ClientRedirectUri>().Where(x => x.ClientId == id))
foreach (var clientRedirectUri in dbContext.Set<ClientRedirectUri>().Where(x => x.ClientId == id))
{
DbContext.Set<ClientRedirectUri>().Remove(clientRedirectUri);
dbContext.Set<ClientRedirectUri>().Remove(clientRedirectUri);
}
foreach (var clientPostLogoutRedirectUri in DbContext.Set<ClientPostLogoutRedirectUri>().Where(x => x.ClientId == id))
foreach (var clientPostLogoutRedirectUri in dbContext.Set<ClientPostLogoutRedirectUri>().Where(x => x.ClientId == id))
{
DbContext.Set<ClientPostLogoutRedirectUri>().Remove(clientPostLogoutRedirectUri);
dbContext.Set<ClientPostLogoutRedirectUri>().Remove(clientPostLogoutRedirectUri);
}
foreach (var clientScope in DbContext.Set<ClientScope>().Where(x => x.ClientId == id))
foreach (var clientScope in dbContext.Set<ClientScope>().Where(x => x.ClientId == id))
{
DbContext.Set<ClientScope>().Remove(clientScope);
dbContext.Set<ClientScope>().Remove(clientScope);
}
foreach (var clientSecret in DbContext.Set<ClientSecret>().Where(x => x.ClientId == id))
foreach (var clientSecret in dbContext.Set<ClientSecret>().Where(x => x.ClientId == id))
{
DbContext.Set<ClientSecret>().Remove(clientSecret);
dbContext.Set<ClientSecret>().Remove(clientSecret);
}
foreach (var clientClaim in DbContext.Set<ClientClaim>().Where(x => x.ClientId == id))
foreach (var clientClaim in dbContext.Set<ClientClaim>().Where(x => x.ClientId == id))
{
DbContext.Set<ClientClaim>().Remove(clientClaim);
dbContext.Set<ClientClaim>().Remove(clientClaim);
}
foreach (var clientIdPRestriction in DbContext.Set<ClientIdPRestriction>().Where(x => x.ClientId == id))
foreach (var clientIdPRestriction in dbContext.Set<ClientIdPRestriction>().Where(x => x.ClientId == id))
{
DbContext.Set<ClientIdPRestriction>().Remove(clientIdPRestriction);
dbContext.Set<ClientIdPRestriction>().Remove(clientIdPRestriction);
}
foreach (var clientCorsOrigin in DbContext.Set<ClientCorsOrigin>().Where(x => x.ClientId == id))
foreach (var clientCorsOrigin in dbContext.Set<ClientCorsOrigin>().Where(x => x.ClientId == id))
{
DbContext.Set<ClientCorsOrigin>().Remove(clientCorsOrigin);
dbContext.Set<ClientCorsOrigin>().Remove(clientCorsOrigin);
}
foreach (var clientProperty in DbContext.Set<ClientProperty>().Where(x => x.ClientId == id))
foreach (var clientProperty in dbContext.Set<ClientProperty>().Where(x => x.ClientId == id))
{
DbContext.Set<ClientProperty>().Remove(clientProperty);
dbContext.Set<ClientProperty>().Remove(clientProperty);
}
await base.DeleteAsync(id, autoSave, cancellationToken);
}
[Obsolete("Use WithDetailsAsync method.")]
public override IQueryable<Client> WithDetails()
{
return GetQueryable().IncludeDetails();
}
public override async Task<IQueryable<Client>> WithDetailsAsync()
{
return (await GetQueryableAsync()).IncludeDetails();
}
}
}

@ -23,7 +23,7 @@ namespace Volo.Abp.IdentityServer.Devices
string userCode,
CancellationToken cancellationToken = default)
{
return await DbSet
return await (await GetDbSetAsync())
.Where(d => d.UserCode == userCode)
.OrderBy(d => d.Id)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
@ -33,7 +33,7 @@ namespace Volo.Abp.IdentityServer.Devices
string deviceCode,
CancellationToken cancellationToken = default)
{
return await DbSet
return await (await GetDbSetAsync())
.Where(d => d.DeviceCode == deviceCode)
.OrderBy(d => d.Id)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
@ -42,7 +42,7 @@ namespace Volo.Abp.IdentityServer.Devices
public virtual async Task<List<DeviceFlowCodes>> GetListByExpirationAsync(DateTime maxExpirationDate, int maxResultCount,
CancellationToken cancellationToken = default)
{
return await DbSet
return await (await GetDbSetAsync())
.Where(x => x.Expiration != null && x.Expiration < maxExpirationDate)
.OrderBy(x => x.ClientId)
.Take(maxResultCount)

@ -21,7 +21,7 @@ namespace Volo.Abp.IdentityServer.Grants
public async Task<List<PersistedGrant>> GetListAsync(string subjectId, string sessionId, string clientId, string type, bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await Filter(subjectId, sessionId, clientId, type)
return await (await FilterAsync(subjectId, sessionId, clientId, type))
.ToListAsync(GetCancellationToken(cancellationToken));
}
@ -29,7 +29,7 @@ namespace Volo.Abp.IdentityServer.Grants
string key,
CancellationToken cancellationToken = default)
{
return await DbSet
return await (await GetDbSetAsync())
.Where(x => x.Key == key)
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
@ -39,7 +39,7 @@ namespace Volo.Abp.IdentityServer.Grants
string subjectId,
CancellationToken cancellationToken = default)
{
return await DbSet
return await (await GetDbSetAsync())
.Where(x => x.SubjectId == subjectId)
.ToListAsync(GetCancellationToken(cancellationToken));
}
@ -49,7 +49,7 @@ namespace Volo.Abp.IdentityServer.Grants
int maxResultCount,
CancellationToken cancellationToken = default)
{
return await DbSet
return await (await GetDbSetAsync())
.Where(x => x.Expiration != null && x.Expiration < maxExpirationDate)
.OrderBy(x => x.ClientId)
.Take(maxResultCount)
@ -63,21 +63,23 @@ namespace Volo.Abp.IdentityServer.Grants
string type = null,
CancellationToken cancellationToken = default)
{
var persistedGrants = await Filter(subjectId, sessionId, clientId, type).ToListAsync(GetCancellationToken(cancellationToken));
var persistedGrants = await (await FilterAsync(subjectId, sessionId, clientId, type)).ToListAsync(GetCancellationToken(cancellationToken));
var dbSet = await GetDbSetAsync();
foreach (var persistedGrant in persistedGrants)
{
DbSet.Remove(persistedGrant);
dbSet.Remove(persistedGrant);
}
}
private IQueryable<PersistedGrant> Filter(
private async Task<IQueryable<PersistedGrant>> FilterAsync(
string subjectId,
string sessionId,
string clientId,
string type)
{
return DbSet
return (await GetDbSetAsync())
.WhereIf(!subjectId.IsNullOrWhiteSpace(), x => x.SubjectId == subjectId)
.WhereIf(!sessionId.IsNullOrWhiteSpace(), x => x.SessionId == sessionId)
.WhereIf(!clientId.IsNullOrWhiteSpace(), x => x.ClientId == clientId)

@ -24,22 +24,28 @@ namespace Volo.Abp.IdentityServer.IdentityResources
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
var query = from identityResource in DbSet.IncludeDetails(includeDetails)
var query = from identityResource in (await GetDbSetAsync()).IncludeDetails(includeDetails)
where scopeNames.Contains(identityResource.Name)
select identityResource;
return await query.ToListAsync(GetCancellationToken(cancellationToken));
}
[Obsolete("Use WithDetailsAsync method.")]
public override IQueryable<IdentityResource> WithDetails()
{
return GetQueryable().IncludeDetails();
}
public override async Task<IQueryable<IdentityResource>> WithDetailsAsync()
{
return (await GetQueryableAsync()).IncludeDetails();
}
public virtual async Task<List<IdentityResource>> GetListAsync(string sorting, int skipCount, int maxResultCount,
string filter, bool includeDetails = false, CancellationToken cancellationToken = default)
{
return await DbSet
return await (await GetDbSetAsync())
.IncludeDetails(includeDetails)
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Name.Contains(filter) ||
x.Description.Contains(filter) ||
@ -54,7 +60,7 @@ namespace Volo.Abp.IdentityServer.IdentityResources
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await DbSet
return await (await GetDbSetAsync())
.IncludeDetails(includeDetails)
.Where(x => x.Name == name)
.OrderBy(x => x.Id)
@ -63,7 +69,7 @@ namespace Volo.Abp.IdentityServer.IdentityResources
public virtual async Task<bool> CheckNameExistAsync(string name, Guid? expectedId = null, CancellationToken cancellationToken = default)
{
return await DbSet.AnyAsync(ir => ir.Id != expectedId && ir.Name == name, cancellationToken: cancellationToken);
return await (await GetDbSetAsync()).AnyAsync(ir => ir.Id != expectedId && ir.Name == name, cancellationToken: cancellationToken);
}
}
}

@ -24,7 +24,7 @@ namespace Volo.Abp.PermissionManagement.EntityFrameworkCore
string providerKey,
CancellationToken cancellationToken = default)
{
return await DbSet
return await (await GetDbSetAsync())
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(s =>
s.Name == name &&
@ -39,7 +39,7 @@ namespace Volo.Abp.PermissionManagement.EntityFrameworkCore
string providerKey,
CancellationToken cancellationToken = default)
{
return await DbSet
return await (await GetDbSetAsync())
.Where(s =>
s.ProviderName == providerName &&
s.ProviderKey == providerKey
@ -49,7 +49,7 @@ namespace Volo.Abp.PermissionManagement.EntityFrameworkCore
public virtual async Task<List<PermissionGrant>> GetListAsync(string[] names, string providerName, string providerKey,
CancellationToken cancellationToken = default)
{
return await DbSet
return await (await GetDbSetAsync())
.Where(s =>
names.Contains(s.Name) &&
s.ProviderName == providerName &&

@ -24,13 +24,14 @@ namespace Volo.Abp.PermissionManagement.MongoDB
string providerKey,
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(s =>
s.Name == name &&
s.ProviderName == providerName &&
s.ProviderKey == providerKey,
GetCancellationToken(cancellationToken)
cancellationToken
);
}
@ -39,22 +40,24 @@ namespace Volo.Abp.PermissionManagement.MongoDB
string providerKey,
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
.Where(s =>
s.ProviderName == providerName &&
s.ProviderKey == providerKey
).ToListAsync(GetCancellationToken(cancellationToken));
).ToListAsync(cancellationToken);
}
public virtual async Task<List<PermissionGrant>> GetListAsync(string[] names, string providerName, string providerKey,
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
.Where(s =>
names.Contains(s.Name) &&
s.ProviderName == providerName &&
s.ProviderKey == providerKey
).ToListAsync(GetCancellationToken(cancellationToken));
).ToListAsync(cancellationToken);
}
}
}

@ -17,7 +17,7 @@ namespace Volo.Abp.SettingManagement.EntityFrameworkCore
public virtual async Task<Setting> FindAsync(string name, string providerName, string providerKey)
{
return await DbSet
return await (await GetDbSetAsync())
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(
s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey
@ -26,7 +26,7 @@ namespace Volo.Abp.SettingManagement.EntityFrameworkCore
public virtual async Task<List<Setting>> GetListAsync(string providerName, string providerKey)
{
return await DbSet
return await (await GetDbSetAsync())
.Where(
s => s.ProviderName == providerName && s.ProviderKey == providerKey
).ToListAsync();
@ -34,7 +34,7 @@ namespace Volo.Abp.SettingManagement.EntityFrameworkCore
public virtual async Task<List<Setting>> GetListAsync(string[] names, string providerName, string providerKey)
{
return await DbSet
return await (await GetDbSetAsync())
.Where(
s => names.Contains(s.Name) && s.ProviderName == providerName && s.ProviderKey == providerKey
).ToListAsync();

@ -19,17 +19,23 @@ namespace Volo.Abp.SettingManagement.MongoDB
public virtual async Task<Setting> FindAsync(string name, string providerName, string providerKey)
{
return await GetMongoQueryable().OrderBy(x => x.Id).FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey);
return await (await GetMongoQueryableAsync())
.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)
{
return await GetMongoQueryable().Where(s => s.ProviderName == providerName && s.ProviderKey == providerKey).ToListAsync();
return await (await GetMongoQueryableAsync())
.Where(s => s.ProviderName == providerName && s.ProviderKey == providerKey)
.ToListAsync();
}
public virtual async Task<List<Setting>> GetListAsync(string[] names, string providerName, string providerKey)
{
return await GetMongoQueryable().Where(s => names.Contains(s.Name) && s.ProviderName == providerName && s.ProviderKey == providerKey).ToListAsync();
return await (await GetMongoQueryableAsync())
.Where(s => names.Contains(s.Name) && s.ProviderName == providerName && s.ProviderKey == providerKey)
.ToListAsync();
}
}
}

@ -27,7 +27,9 @@ namespace Volo.Abp.Users.EntityFrameworkCore
public virtual async Task<List<TUser>> GetListAsync(IEnumerable<Guid> ids, CancellationToken cancellationToken = default)
{
return await DbSet.Where(u => ids.Contains(u.Id)).ToListAsync(GetCancellationToken(cancellationToken));
return await (await GetDbSetAsync())
.Where(u => ids.Contains(u.Id))
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<List<TUser>> SearchAsync(
@ -37,7 +39,7 @@ namespace Volo.Abp.Users.EntityFrameworkCore
string filter = null,
CancellationToken cancellationToken = default)
{
return await DbSet
return await (await GetDbSetAsync())
.WhereIf(
!filter.IsNullOrWhiteSpace(),
u =>
@ -55,7 +57,7 @@ namespace Volo.Abp.Users.EntityFrameworkCore
string filter = null,
CancellationToken cancellationToken = default)
{
return await DbSet
return await (await GetDbSetAsync())
.WhereIf(
!filter.IsNullOrWhiteSpace(),
u =>

@ -23,12 +23,18 @@ namespace Volo.Abp.Users.MongoDB
public virtual async Task<TUser> FindByUserNameAsync(string userName, CancellationToken cancellationToken = default)
{
return await GetMongoQueryable().OrderBy(x => x.Id).FirstOrDefaultAsync(u => u.UserName == userName, GetCancellationToken(cancellationToken));
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(u => u.UserName == userName, cancellationToken);
}
public virtual async Task<List<TUser>> GetListAsync(IEnumerable<Guid> ids, CancellationToken cancellationToken = default)
{
return await GetMongoQueryable().Where(u => ids.Contains(u.Id)).ToListAsync(GetCancellationToken(cancellationToken));
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
.Where(u => ids.Contains(u.Id))
.ToListAsync(cancellationToken);
}
public async Task<List<TUser>> SearchAsync(
@ -38,7 +44,8 @@ namespace Volo.Abp.Users.MongoDB
string filter = null,
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
.WhereIf<TUser, IMongoQueryable<TUser>>(
!filter.IsNullOrWhiteSpace(),
u =>
@ -50,12 +57,13 @@ namespace Volo.Abp.Users.MongoDB
.OrderBy(sorting ?? nameof(IUserData.UserName))
.As<IMongoQueryable<TUser>>()
.PageBy<TUser, IMongoQueryable<TUser>>(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
.ToListAsync(cancellationToken);
}
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
.WhereIf<TUser, IMongoQueryable<TUser>>(
!filter.IsNullOrWhiteSpace(),
u =>
@ -64,7 +72,7 @@ namespace Volo.Abp.Users.MongoDB
u.Name.Contains(filter) ||
u.Surname.Contains(filter)
)
.LongCountAsync(GetCancellationToken(cancellationToken));
.LongCountAsync(cancellationToken);
}
}
}

Loading…
Cancel
Save