Browse Source

Rename `GetMongoQueryable` to `GetQueryable`.

pull/21807/head
maliming 2 years ago
parent
commit
9ede7b4340
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 8
      docs/en/framework/architecture/best-practices/mongodb-integration.md
  2. 4
      docs/en/guides/microservice-mongodb.md
  3. 4
      docs/en/tutorials/book-store/part-07.md
  4. 5
      framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/IMongoDbRepository.cs
  5. 42
      framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs
  6. 10
      framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDbCoreRepositoryExtensions.cs
  7. 6
      framework/test/Volo.Abp.MongoDB.Tests/Volo/Abp/MongoDB/Repositories/Repository_Basic_Tests.cs
  8. 12
      modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs
  9. 2
      modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/MongoBackgroundJobRepository.cs
  10. 4
      modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoDbDatabaseBlobRepository.cs
  11. 2
      modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Blogs/MongoBlogRepository.cs
  12. 8
      modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Comments/MongoCommentRepository.cs
  13. 12
      modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Posts/MongoPostRepository.cs
  14. 10
      modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Tagging/MongoTagRepository.cs
  15. 2
      modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Users/MongoBlogUserRepository.cs
  16. 4
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogFeatureRepository.cs
  17. 10
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogPostRepository.cs
  18. 8
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs
  19. 14
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs
  20. 6
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/MarkedItems/MongoUserMarkedItemRepository.cs
  21. 8
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Pages/MongoPageRepository.cs
  22. 4
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Ratings/MongoRatingRepository.cs
  23. 6
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Reactions/MongoUserReactionRepository.cs
  24. 2
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoEntityTagRepository.cs
  25. 12
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs
  26. 22
      modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs
  27. 8
      modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Projects/MongoProjectRepository.cs
  28. 2
      modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/MongoFeatureDefinitionRecordRepository.cs
  29. 6
      modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/MongoFeatureValueRepository.cs
  30. 10
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityClaimTypeRepository.cs
  31. 6
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityLinkUserRepository.cs
  32. 14
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityRoleRepository.cs
  33. 4
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentitySecurityLogRepository.cs
  34. 10
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentitySessionRepository.cs
  35. 6
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserDelegationRepository.cs
  36. 54
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs
  37. 34
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoOrganizationUnitRepository.cs
  38. 12
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiResourceRepository.cs
  39. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiScopeRepository.cs
  40. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoClientRepository.cs
  41. 6
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoDeviceFlowCodesRepository.cs
  42. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoIdentityResourceRepository.cs
  43. 8
      modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoPersistentGrantRepository.cs
  44. 14
      modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Applications/MongoOpenIddictApplicationRepository.cs
  45. 16
      modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Authorizations/MongoOpenIddictAuthorizationRepository.cs
  46. 14
      modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Scopes/MongoOpenIddictScopeRepository.cs
  47. 24
      modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Tokens/MongoOpenIddictTokenRepository.cs
  48. 2
      modules/permission-management/src/Volo.Abp.PermissionManagement.MongoDB/Volo/Abp/PermissionManagement/MongoDb/MongoPermissionDefinitionRecordRepository.cs
  49. 6
      modules/permission-management/src/Volo.Abp.PermissionManagement.MongoDB/Volo/Abp/PermissionManagement/MongoDb/MongoPermissionGrantRepository.cs
  50. 2
      modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/MongoSettingDefinitionRecordRepository.cs
  51. 6
      modules/setting-management/src/Volo.Abp.SettingManagement.MongoDB/Volo/Abp/SettingManagement/MongoDB/MongoSettingRepository.cs
  52. 10
      modules/tenant-management/src/Volo.Abp.TenantManagement.MongoDB/Volo/Abp/TenantManagement/MongoDb/MongoTenantRepository.cs
  53. 8
      modules/users/src/Volo.Abp.Users.MongoDB/Volo/Abp/Users/MongoDB/MongoUserRepositoryBase.cs
  54. 2
      templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/Samples/SampleRepositoryTests.cs

8
docs/en/framework/architecture/best-practices/mongodb-integration.md

@ -114,7 +114,7 @@ public async Task<IdentityUser> FindByNormalizedUserNameAsync(
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync())
return await (await GetQueryableAsync())
.FirstOrDefaultAsync(
u => u.NormalizedUserName == normalizedUserName,
GetCancellationToken(cancellationToken)
@ -125,10 +125,10 @@ public async Task<IdentityUser> FindByNormalizedUserNameAsync(
`GetCancellationToken` fallbacks to the `ICancellationTokenProvider.Token` to obtain the cancellation token if it is not provided by the caller code.
* **Do** ignore the `includeDetails` parameters for the repository implementation since MongoDB loads the aggregate root as a whole (including sub collections) by default.
* **Do** use the `GetMongoQueryableAsync()` method to obtain an `IQueryable<TEntity>` to perform queries wherever possible. Because;
* `GetMongoQueryableAsync()` method automatically uses the `ApplyDataFilters` method to filter the data based on the current data filters (like soft delete and multi-tenancy).
* **Do** use the `GetQueryableAsync()` method to obtain an `IQueryable<TEntity>` to perform queries wherever possible. Because;
* `GetQueryableAsync()` method automatically uses the `ApplyDataFilters` method to filter the data based on the current data filters (like soft delete and multi-tenancy).
* Using `IQueryable<TEntity>` makes the code as much as similar to the EF Core repository implementation and easy to write and read.
* **Do** implement data filtering if it is not possible to use the `GetMongoQueryable()` method.
* **Do** implement data filtering if it is not possible to use the `GetQueryable()` method.
## Module Class

4
docs/en/guides/microservice-mongodb.md

@ -97,7 +97,7 @@ Here we use `BookStore.ProductService` project as an example:
int skipCount = 0,
CancellationToken cancellationToken = default)
{
var query = ApplyFilter(await GetMongoQueryableAsync(cancellationToken), filterText, name, priceMin, priceMax);
var query = ApplyFilter(await GetQueryableAsync(cancellationToken), filterText, name, priceMin, priceMax);
query = query.OrderBy(string.IsNullOrWhiteSpace(sorting) ? ProductConsts.GetDefaultSorting(false) : sorting);
return await query.PageBy(skipCount, maxResultCount).ToListAsync(cancellationToken);
}
@ -109,7 +109,7 @@ Here we use `BookStore.ProductService` project as an example:
float? priceMax = null,
CancellationToken cancellationToken = default)
{
var query = ApplyFilter(await GetMongoQueryableAsync(cancellationToken), filterText, name, priceMin, priceMax);
var query = ApplyFilter(await GetQueryableAsync(cancellationToken), filterText, name, priceMin, priceMax);
return await query.LongCountAsync(GetCancellationToken(cancellationToken));
}

4
docs/en/tutorials/book-store/part-07.md

@ -180,7 +180,7 @@ public class MongoDbAuthorRepository
public async Task<Author> FindByNameAsync(string name)
{
var queryable = await GetMongoQueryableAsync();
var queryable = await GetQueryableAsync();
return await queryable.FirstOrDefaultAsync(author => author.Name == name);
}
@ -190,7 +190,7 @@ public class MongoDbAuthorRepository
string sorting,
string filter = null)
{
var queryable = await GetMongoQueryableAsync();
var queryable = await GetQueryableAsync();
return await queryable
.WhereIf<Author, IQueryable<Author>>(
!filter.IsNullOrWhiteSpace(),

5
framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/IMongoDbRepository.cs

@ -21,10 +21,7 @@ public interface IMongoDbRepository<TEntity> : IRepository<TEntity>
Task<IMongoCollection<TEntity>> GetCollectionAsync(CancellationToken cancellationToken = default);
[Obsolete("Use GetMongoQueryableAsync method.")]
IQueryable<TEntity> GetMongoQueryable();
Task<IQueryable<TEntity>> GetMongoQueryableAsync(CancellationToken cancellationToken = default, AggregateOptions? options = null);
Task<IQueryable<TEntity>> GetQueryableAsync(CancellationToken cancellationToken = default, AggregateOptions? options = null);
Task<IAggregateFluent<TEntity>> GetAggregateAsync(CancellationToken cancellationToken = default, AggregateOptions? options = null);
}

42
framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs

@ -455,19 +455,19 @@ public class MongoDbRepository<TMongoDbContext, TEntity>
public async override Task<List<TEntity>> GetListAsync(bool includeDetails = false, CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken)).ToListAsync(cancellationToken);
return await (await GetQueryableAsync(cancellationToken)).ToListAsync(cancellationToken);
}
public async override Task<List<TEntity>> GetListAsync(Expression<Func<TEntity, bool>> predicate, bool includeDetails = false, CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken)).Where(predicate).ToListAsync(cancellationToken);
return await (await GetQueryableAsync(cancellationToken)).Where(predicate).ToListAsync(cancellationToken);
}
public async override Task<long> GetCountAsync(CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken)).LongCountAsync(cancellationToken);
return await (await GetQueryableAsync(cancellationToken)).LongCountAsync(cancellationToken);
}
public async override Task<List<TEntity>> GetPagedListAsync(
@ -479,7 +479,7 @@ public class MongoDbRepository<TMongoDbContext, TEntity>
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.OrderByIf<TEntity, IQueryable<TEntity>>(!sorting.IsNullOrWhiteSpace(), sorting)
.PageBy<TEntity, IQueryable<TEntity>>(skipCount, maxResultCount)
.ToListAsync(cancellationToken);
@ -492,7 +492,7 @@ public class MongoDbRepository<TMongoDbContext, TEntity>
{
cancellationToken = GetCancellationToken(cancellationToken);
var entities = await (await GetMongoQueryableAsync(cancellationToken))
var entities = await (await GetQueryableAsync(cancellationToken))
.Where(predicate)
.ToListAsync(cancellationToken);
@ -523,17 +523,6 @@ public class MongoDbRepository<TMongoDbContext, TEntity>
}
}
[Obsolete("Use GetQueryableAsync method.")]
protected override IQueryable<TEntity> GetQueryable()
{
return GetMongoQueryable();
}
public async override Task<IQueryable<TEntity>> GetQueryableAsync()
{
return await GetMongoQueryableAsync();
}
public async override Task<TEntity?> FindAsync(
Expression<Func<TEntity, bool>> predicate,
bool includeDetails = true,
@ -541,13 +530,13 @@ public class MongoDbRepository<TMongoDbContext, TEntity>
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(predicate)
.SingleOrDefaultAsync(cancellationToken);
}
[Obsolete("Use GetMongoQueryableAsync method.")]
public virtual IQueryable<TEntity> GetMongoQueryable()
[Obsolete("Use GetQueryableAsync method.")]
protected override IQueryable<TEntity> GetQueryable()
{
return ApplyDataFilters(
SessionHandle != null
@ -556,12 +545,17 @@ public class MongoDbRepository<TMongoDbContext, TEntity>
);
}
public virtual Task<IQueryable<TEntity>> GetMongoQueryableAsync(CancellationToken cancellationToken = default, AggregateOptions? aggregateOptions = null)
public async override Task<IQueryable<TEntity>> GetQueryableAsync()
{
return await GetQueryableAsync<TEntity>();
}
public async Task<IQueryable<TEntity>> GetQueryableAsync(CancellationToken cancellationToken = default, AggregateOptions? options = null)
{
return GetMongoQueryableAsync<TEntity>(cancellationToken, aggregateOptions);
return await GetQueryableAsync<TEntity>(cancellationToken, options);
}
protected virtual async Task<IQueryable<TOtherEntity>> GetMongoQueryableAsync<TOtherEntity>(CancellationToken cancellationToken = default, AggregateOptions? aggregateOptions = null)
protected virtual async Task<IQueryable<TOtherEntity>> GetQueryableAsync<TOtherEntity>(CancellationToken cancellationToken = default, AggregateOptions? aggregateOptions = null)
{
cancellationToken = GetCancellationToken(cancellationToken);
@ -809,7 +803,7 @@ public class MongoDbRepository<TMongoDbContext, TEntity, TKey>
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(x => x.Id!.Equals(id))
.FirstOrDefaultAsync(cancellationToken);
}
@ -826,7 +820,7 @@ public class MongoDbRepository<TMongoDbContext, TEntity, TKey>
{
cancellationToken = GetCancellationToken(cancellationToken);
var entities = await (await GetMongoQueryableAsync(cancellationToken))
var entities = await (await GetQueryableAsync(cancellationToken))
.Where(x => ids.Contains(x.Id))
.ToListAsync(cancellationToken);

10
framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDbCoreRepositoryExtensions.cs

@ -37,17 +37,17 @@ public static class MongoDbCoreRepositoryExtensions
return repository.ToMongoDbRepository().GetCollectionAsync(cancellationToken);
}
[Obsolete("Use GetMongoQueryableAsync method.")]
public static IQueryable<TEntity> GetMongoQueryable<TEntity>(this IReadOnlyBasicRepository<TEntity> repository)
[Obsolete("Use GetQueryableAsync method.")]
public static IQueryable<TEntity> GetQueryable<TEntity>(this IReadOnlyBasicRepository<TEntity> repository)
where TEntity : class, IEntity
{
return repository.ToMongoDbRepository().GetMongoQueryable();
return repository.ToMongoDbRepository().GetQueryable();
}
public static Task<IQueryable<TEntity>> GetMongoQueryableAsync<TEntity>(this IReadOnlyBasicRepository<TEntity> repository, CancellationToken cancellationToken = default, AggregateOptions? aggregateOptions = null)
public static Task<IQueryable<TEntity>> GetQueryableAsync<TEntity>(this IReadOnlyBasicRepository<TEntity> repository, CancellationToken cancellationToken = default, AggregateOptions? aggregateOptions = null)
where TEntity : class, IEntity
{
return repository.ToMongoDbRepository().GetMongoQueryableAsync(cancellationToken, aggregateOptions);
return repository.ToMongoDbRepository().GetQueryableAsync(cancellationToken, aggregateOptions);
}
public static Task<IAggregateFluent<TEntity>> GetAggregateAsync<TEntity>(this IReadOnlyBasicRepository<TEntity> repository, CancellationToken cancellationToken = default, AggregateOptions? aggregateOptions = null)

6
framework/test/Volo.Abp.MongoDB.Tests/Volo/Abp/MongoDB/Repositories/Repository_Basic_Tests.cs

@ -69,9 +69,9 @@ public class Repository_Basic_Tests : Repository_Basic_Tests<AbpMongoDbTestModul
[Fact]
public async Task Filter_Case_Insensitive()
{
(await CityRepository.GetMongoQueryableAsync()).FirstOrDefault(c => c.Name == "ISTANBUL").ShouldBeNull();
(await CityRepository.GetMongoQueryableAsync()).FirstOrDefault(c => c.Name == "istanbul").ShouldBeNull();
(await CityRepository.GetMongoQueryableAsync()).FirstOrDefault(c => c.Name == "Istanbul").ShouldNotBeNull();
(await CityRepository.GetQueryableAsync()).FirstOrDefault(c => c.Name == "ISTANBUL").ShouldBeNull();
(await CityRepository.GetQueryableAsync()).FirstOrDefault(c => c.Name == "istanbul").ShouldBeNull();
(await CityRepository.GetQueryableAsync()).FirstOrDefault(c => c.Name == "Istanbul").ShouldNotBeNull();
(await PersonRepository.GetQueryableAsync()).FirstOrDefault(p => p.Name == "douglas").ShouldNotBeNull();
(await PersonRepository.GetQueryableAsync()).FirstOrDefault(p => p.Name == "DOUGLAS").ShouldNotBeNull();

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

@ -126,7 +126,7 @@ public class MongoAuditLogRepository : MongoDbRepository<IAuditLoggingMongoDbCon
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return (await GetMongoQueryableAsync(cancellationToken))
return (await GetQueryableAsync(cancellationToken))
.WhereIf(startTime.HasValue, auditLog => auditLog.ExecutionTime >= startTime)
.WhereIf(endTime.HasValue, auditLog => auditLog.ExecutionTime <= endTime)
.WhereIf(hasException.HasValue && hasException.Value, auditLog => auditLog.Exceptions != null && auditLog.Exceptions != "")
@ -149,7 +149,7 @@ public class MongoAuditLogRepository : MongoDbRepository<IAuditLoggingMongoDbCon
DateTime endDate,
CancellationToken cancellationToken = default)
{
var result = await (await GetMongoQueryableAsync(cancellationToken))
var result = await (await GetQueryableAsync(cancellationToken))
.Where(a => a.ExecutionTime < endDate.AddDays(1) && a.ExecutionTime > startDate)
.OrderBy(t => t.ExecutionTime)
.GroupBy(t => new {
@ -167,7 +167,7 @@ public class MongoAuditLogRepository : MongoDbRepository<IAuditLoggingMongoDbCon
Guid entityChangeId,
CancellationToken cancellationToken = default)
{
var entityChange = (await (await GetMongoQueryableAsync(cancellationToken))
var entityChange = (await (await GetQueryableAsync(cancellationToken))
.Where(x => x.EntityChanges.Any(y => y.Id == entityChangeId))
.OrderBy(x => x.Id)
.FirstAsync(GetCancellationToken(cancellationToken))).EntityChanges.FirstOrDefault(x => x.Id == entityChangeId);
@ -221,7 +221,7 @@ public class MongoAuditLogRepository : MongoDbRepository<IAuditLoggingMongoDbCon
Guid entityChangeId,
CancellationToken cancellationToken = default)
{
var auditLog = await (await GetMongoQueryableAsync(cancellationToken))
var auditLog = await (await GetQueryableAsync(cancellationToken))
.Where(x => x.EntityChanges.Any(y => y.Id == entityChangeId))
.FirstAsync(GetCancellationToken(cancellationToken));
@ -237,7 +237,7 @@ public class MongoAuditLogRepository : MongoDbRepository<IAuditLoggingMongoDbCon
string entityTypeFullName,
CancellationToken cancellationToken = default)
{
var auditLogs = await (await GetMongoQueryableAsync(cancellationToken))
var auditLogs = await (await GetQueryableAsync(cancellationToken))
.Where(x => x.EntityChanges.Any(y => y.EntityId == entityId && y.EntityTypeFullName == entityTypeFullName))
.OrderByDescending(x => x.ExecutionTime)
.ToListAsync(GetCancellationToken(cancellationToken));
@ -259,7 +259,7 @@ public class MongoAuditLogRepository : MongoDbRepository<IAuditLoggingMongoDbCon
string entityTypeFullName = null,
CancellationToken cancellationToken = default)
{
return (await GetMongoQueryableAsync(cancellationToken))
return (await GetQueryableAsync(cancellationToken))
.SelectMany(x => x.EntityChanges)
.WhereIf(auditLogId.HasValue, e => e.Id == auditLogId)
.WhereIf(startTime.HasValue, e => e.ChangeTime >= startTime)

2
modules/background-jobs/src/Volo.Abp.BackgroundJobs.MongoDB/Volo/Abp/BackgroundJobs/MongoDB/MongoBackgroundJobRepository.cs

@ -33,7 +33,7 @@ public class MongoBackgroundJobRepository : MongoDbRepository<IBackgroundJobsMon
protected virtual async Task<IQueryable<BackgroundJobRecord>> GetWaitingListQuery(int maxResultCount, CancellationToken cancellationToken = default)
{
var now = Clock.Now;
return (await GetMongoQueryableAsync(cancellationToken))
return (await GetQueryableAsync(cancellationToken))
.Where(t => !t.IsAbandoned && t.NextTryTime <= now)
.OrderByDescending(t => t.Priority)
.ThenBy(t => t.TryCount)

4
modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoDbDatabaseBlobRepository.cs

@ -17,7 +17,7 @@ public class MongoDbDatabaseBlobRepository : MongoDbRepository<IBlobStoringMongo
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.FirstOrDefaultAsync(
x => x.ContainerId == containerId && x.Name == name,
cancellationToken
@ -28,7 +28,7 @@ public class MongoDbDatabaseBlobRepository : MongoDbRepository<IBlobStoringMongo
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.AnyAsync(
x => x.ContainerId == containerId && x.Name == name,
cancellationToken

2
modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Blogs/MongoBlogRepository.cs

@ -16,7 +16,7 @@ namespace Volo.Blogging.Blogs
public virtual async Task<Blog> FindByShortNameAsync(string shortName, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).FirstOrDefaultAsync(p => p.ShortName == shortName, GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync(cancellationToken)).FirstOrDefaultAsync(p => p.ShortName == shortName, GetCancellationToken(cancellationToken));
}
}
}

8
modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Comments/MongoCommentRepository.cs

@ -19,7 +19,7 @@ namespace Volo.Blogging.Comments
public virtual async Task<List<Comment>> GetListOfPostAsync(Guid postId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(a => a.PostId == postId)
.OrderBy(a => a.CreationTime)
.ToListAsync(GetCancellationToken(cancellationToken));
@ -27,19 +27,19 @@ namespace Volo.Blogging.Comments
public virtual async Task<int> GetCommentCountOfPostAsync(Guid postId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.CountAsync(a => a.PostId == postId, GetCancellationToken(cancellationToken));
}
public virtual async Task<List<Comment>> GetRepliesOfComment(Guid id, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(a => a.RepliedCommentId == id).ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task DeleteOfPost(Guid id, CancellationToken cancellationToken = default)
{
var recordsToDelete = (await GetMongoQueryableAsync(cancellationToken)).Where(pt => pt.PostId == id);
var recordsToDelete = (await GetQueryableAsync(cancellationToken)).Where(pt => pt.PostId == id);
foreach (var record in recordsToDelete)
{

12
modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Posts/MongoPostRepository.cs

@ -21,13 +21,13 @@ namespace Volo.Blogging.Posts
public virtual async Task<List<Post>> GetPostsByBlogId(Guid id, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).Where(p => p.BlogId == id).OrderByDescending(p => p.CreationTime).ToListAsync(GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync(cancellationToken)).Where(p => p.BlogId == id).OrderByDescending(p => p.CreationTime).ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<bool> IsPostUrlInUseAsync(Guid blogId, string url, Guid? excludingPostId = null, CancellationToken cancellationToken = default)
{
var query = (await GetMongoQueryableAsync(cancellationToken)).Where(p => blogId == p.BlogId && p.Url == url);
var query = (await GetQueryableAsync(cancellationToken)).Where(p => blogId == p.BlogId && p.Url == url);
if (excludingPostId != null)
{
@ -39,7 +39,7 @@ namespace Volo.Blogging.Posts
public virtual async Task<Post> GetPostByUrl(Guid blogId, string url, CancellationToken cancellationToken = default)
{
var post = await (await GetMongoQueryableAsync(cancellationToken)).FirstOrDefaultAsync(p => p.BlogId == blogId && p.Url == url, GetCancellationToken(cancellationToken));
var post = await (await GetQueryableAsync(cancellationToken)).FirstOrDefaultAsync(p => p.BlogId == blogId && p.Url == url, GetCancellationToken(cancellationToken));
if (post == null)
{
@ -51,7 +51,7 @@ namespace Volo.Blogging.Posts
public virtual async Task<List<Post>> GetOrderedList(Guid blogId, bool @descending = false, CancellationToken cancellationToken = default)
{
var query = (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.BlogId == blogId);
var query = (await GetQueryableAsync(cancellationToken)).Where(x => x.BlogId == blogId);
if (!descending)
{
@ -63,7 +63,7 @@ namespace Volo.Blogging.Posts
public virtual async Task<List<Post>> GetListByUserIdAsync(Guid userId, CancellationToken cancellationToken = default)
{
var query = (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.CreatorId == userId)
var query = (await GetQueryableAsync(cancellationToken)).Where(x => x.CreatorId == userId)
.OrderByDescending(x => x.CreationTime);
return await query.ToListAsync(GetCancellationToken(cancellationToken));
@ -71,7 +71,7 @@ namespace Volo.Blogging.Posts
public virtual async Task<List<Post>> GetLatestBlogPostsAsync(Guid blogId, int count, CancellationToken cancellationToken = default)
{
var query = (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.BlogId == blogId)
var query = (await GetQueryableAsync(cancellationToken)).Where(x => x.BlogId == blogId)
.OrderByDescending(x => x.CreationTime)
.Take(count);

10
modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Tagging/MongoTagRepository.cs

@ -20,27 +20,27 @@ namespace Volo.Blogging.Tagging
public virtual async Task<List<Tag>> GetListAsync(Guid blogId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).Where(t => t.BlogId == blogId).ToListAsync(GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync(cancellationToken)).Where(t => t.BlogId == blogId).ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<Tag> GetByNameAsync(Guid blogId, string name, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).Where(t => t.BlogId == blogId && t.Name == name).FirstAsync(GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync(cancellationToken)).Where(t => t.BlogId == blogId && t.Name == name).FirstAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<Tag> FindByNameAsync(Guid blogId, string name, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).Where(t => t.BlogId == blogId && t.Name == name).FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync(cancellationToken)).Where(t => t.BlogId == blogId && t.Name == name).FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<Tag>> GetListAsync(IEnumerable<Guid> ids, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).Where(t => ids.Contains(t.Id)).ToListAsync(GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync(cancellationToken)).Where(t => ids.Contains(t.Id)).ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task DecreaseUsageCountOfTagsAsync(List<Guid> ids, CancellationToken cancellationToken = default)
{
var tags = await (await GetMongoQueryableAsync(cancellationToken))
var tags = await (await GetQueryableAsync(cancellationToken))
.Where(t => ids.Contains(t.Id))
.ToListAsync(GetCancellationToken(cancellationToken));

2
modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Users/MongoBlogUserRepository.cs

@ -18,7 +18,7 @@ namespace Volo.Blogging.Users
public virtual async Task<List<BlogUser>> GetUsersAsync(int maxCount, string filter, CancellationToken cancellationToken = default)
{
var query = await GetMongoQueryableAsync(cancellationToken);
var query = await GetQueryableAsync(cancellationToken);
if (!string.IsNullOrWhiteSpace(filter))
{

4
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogFeatureRepository.cs

@ -25,14 +25,14 @@ public class MongoBlogFeatureRepository : MongoDbRepository<ICmsKitMongoDbContex
public virtual async Task<List<BlogFeature>> GetListAsync(Guid blogId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(x => x.BlogId == blogId)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<BlogFeature>> GetListAsync(Guid blogId, List<string> featureNames, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(x => x.BlogId == blogId && featureNames.Contains(x.FeatureName))
.ToListAsync(GetCancellationToken(cancellationToken));
}

10
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogPostRepository.cs

@ -44,7 +44,7 @@ public class MongoBlogPostRepository : MongoDbRepository<CmsKitMongoDbContext, B
x.Slug.ToLower() == slug,
cancellationToken: token);
blogPost.Author = await (await GetMongoQueryableAsync<CmsUser>(token)).FirstOrDefaultAsync(x => x.Id == blogPost.AuthorId, token);
blogPost.Author = await (await GetQueryableAsync<CmsUser>(token)).FirstOrDefaultAsync(x => x.Id == blogPost.AuthorId, token);
return blogPost;
}
@ -64,7 +64,7 @@ public class MongoBlogPostRepository : MongoDbRepository<CmsKitMongoDbContext, B
var favoriteUserFilteredEntityIds = await GetFavoriteEntityIdsByUserId(favoriteUserId, cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(tagFilteredEntityIds.Any(), x => tagFilteredEntityIds.Contains(x.Id))
.WhereIf(favoriteUserFilteredEntityIds.Any(), x => favoriteUserFilteredEntityIds.Contains(x.Id))
.WhereIf(!string.IsNullOrWhiteSpace(filter), x => x.Title.Contains(filter) || x.Slug.Contains(filter))
@ -174,7 +174,7 @@ public class MongoBlogPostRepository : MongoDbRepository<CmsKitMongoDbContext, B
Check.NotNullOrEmpty(slug, nameof(slug));
cancellationToken = GetCancellationToken(cancellationToken);
var queryable = await GetMongoQueryableAsync(cancellationToken);
var queryable = await GetQueryableAsync(cancellationToken);
return await queryable.AnyAsync(x => x.BlogId == blogId && x.Slug.ToLower() == slug, cancellationToken);
}
@ -225,14 +225,14 @@ public class MongoBlogPostRepository : MongoDbRepository<CmsKitMongoDbContext, B
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.AnyAsync(x => x.Status == BlogPostStatus.WaitingForReview, cancellationToken);
}
public async Task UpdateBlogAsync(Guid sourceBlogId, Guid? targetBlogId, CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
var blogPosts = await (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.BlogId == sourceBlogId).ToListAsync(cancellationToken);
var blogPosts = await (await GetQueryableAsync(cancellationToken)).Where(x => x.BlogId == sourceBlogId).ToListAsync(cancellationToken);
if (targetBlogId.HasValue)
{
foreach (var blogPost in blogPosts)

8
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs

@ -23,13 +23,13 @@ public class MongoBlogRepository : MongoDbRepository<ICmsKitMongoDbContext, Blog
public virtual async Task<bool> ExistsAsync(Guid id, CancellationToken cancellationToken = default)
{
var token = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(token)).AnyAsync(x => x.Id == id, token);
return await (await GetQueryableAsync(token)).AnyAsync(x => x.Id == id, token);
}
public virtual async Task<bool> SlugExistsAsync(string slug, CancellationToken cancellationToken = default)
{
var token = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(token)).AnyAsync(x => x.Slug == slug, token);
return await (await GetQueryableAsync(token)).AnyAsync(x => x.Slug == slug, token);
}
public virtual async Task<List<Blog>> GetListAsync(
@ -62,7 +62,7 @@ public class MongoBlogRepository : MongoDbRepository<ICmsKitMongoDbContext, Blog
var blogIds = blogs.OrderBy(sorting.IsNullOrEmpty() ? "creationTime desc" : sorting)
.PageBy(skipCount, maxResultCount).Select(x => x.Id).ToList();
var blogPostCount = await (await GetMongoQueryableAsync<BlogPost>(token))
var blogPostCount = await (await GetQueryableAsync<BlogPost>(token))
.Where(blogPost => blogIds.Contains(blogPost.Id))
.GroupBy(blogPost => blogPost.BlogId)
.Select(x => new
@ -92,7 +92,7 @@ public class MongoBlogRepository : MongoDbRepository<ICmsKitMongoDbContext, Blog
protected virtual async Task<IQueryable<Blog>> GetListQueryAsync(string filter = null, CancellationToken cancellationToken = default)
{
return (await GetMongoQueryableAsync(cancellationToken))
return (await GetQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrWhiteSpace(), b => b.Name.Contains(filter));
}
}

14
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs

@ -66,7 +66,7 @@ public class MongoCommentRepository : MongoDbRepository<ICmsKitMongoDbContext, C
var commentIds = comments.Select(x => x.Id).ToList();
var authorsQuery = from comment in (await GetMongoQueryableAsync(token))
var authorsQuery = from comment in (await GetQueryableAsync(token))
join user in (await GetDbContextAsync(token)).CmsUsers on comment.CreatorId equals user.Id
where commentIds.Contains(comment.Id)
orderby comment.CreationTime
@ -115,7 +115,7 @@ public class MongoCommentRepository : MongoDbRepository<ICmsKitMongoDbContext, C
Check.NotNullOrWhiteSpace(entityType, nameof(entityType));
Check.NotNullOrWhiteSpace(entityId, nameof(entityId));
var authorsQuery = from comment in (await GetMongoQueryableAsync(cancellationToken))
var authorsQuery = from comment in (await GetQueryableAsync(cancellationToken))
join user in (await GetDbContextAsync(cancellationToken)).CmsUsers on comment.CreatorId equals user.Id
where entityType == comment.EntityType && entityId == comment.EntityId
orderby comment.CreationTime
@ -123,7 +123,7 @@ public class MongoCommentRepository : MongoDbRepository<ICmsKitMongoDbContext, C
var authors = await ApplyDataFilters<IQueryable<CmsUser>, CmsUser>(authorsQuery).ToListAsync(GetCancellationToken(cancellationToken));
var commentsQuery = (await GetMongoQueryableAsync(cancellationToken))
var commentsQuery = (await GetQueryableAsync(cancellationToken))
.Where(c => c.EntityId == entityId && c.EntityType == entityType);
commentsQuery = commentApproveState switch {
@ -150,7 +150,7 @@ public class MongoCommentRepository : MongoDbRepository<ICmsKitMongoDbContext, C
Comment comment,
CancellationToken cancellationToken = default)
{
var replies = await (await GetMongoQueryableAsync(cancellationToken))
var replies = await (await GetQueryableAsync(cancellationToken))
.Where(x => x.RepliedCommentId == comment.Id)
.ToListAsync(GetCancellationToken(cancellationToken));
@ -170,7 +170,7 @@ public class MongoCommentRepository : MongoDbRepository<ICmsKitMongoDbContext, C
public virtual async Task<bool> ExistsAsync(string idempotencyToken, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.AnyAsync(x => x.IdempotencyToken == idempotencyToken, GetCancellationToken(cancellationToken));
}
@ -185,11 +185,11 @@ public class MongoCommentRepository : MongoDbRepository<ICmsKitMongoDbContext, C
CancellationToken cancellationToken = default
)
{
var queryable = await GetMongoQueryableAsync(cancellationToken);
var queryable = await GetQueryableAsync(cancellationToken);
if (!string.IsNullOrEmpty(authorUsername))
{
var author = await (await GetMongoQueryableAsync<CmsUser>(cancellationToken)).FirstOrDefaultAsync(x => x.UserName == authorUsername, cancellationToken: cancellationToken);
var author = await (await GetQueryableAsync<CmsUser>(cancellationToken)).FirstOrDefaultAsync(x => x.UserName == authorUsername, cancellationToken: cancellationToken);
var authorId = author?.Id ?? Guid.Empty;

6
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/MarkedItems/MongoUserMarkedItemRepository.cs

@ -24,7 +24,7 @@ public class MongoUserMarkedItemRepository : MongoDbRepository<ICmsKitMongoDbCon
Check.NotNullOrWhiteSpace(entityType, nameof(entityType));
Check.NotNull(entityId, nameof(entityId));
var entity = await (await GetMongoQueryableAsync(cancellationToken))
var entity = await (await GetQueryableAsync(cancellationToken))
.Where(x =>
x.CreatorId == userId &&
x.EntityType == entityType &&
@ -39,7 +39,7 @@ public class MongoUserMarkedItemRepository : MongoDbRepository<ICmsKitMongoDbCon
Check.NotNull(userId, nameof(userId));
Check.NotNullOrWhiteSpace(entityType, nameof(entityType));
return await(await GetMongoQueryableAsync(cancellationToken))
return await(await GetQueryableAsync(cancellationToken))
.Where(x =>
x.CreatorId == userId &&
x.EntityType == entityType)
@ -49,7 +49,7 @@ public class MongoUserMarkedItemRepository : MongoDbRepository<ICmsKitMongoDbCon
public virtual async Task<List<string>> GetEntityIdsFilteredByUserAsync([NotNull] Guid userId, [NotNull] string entityType, [CanBeNull] Guid? tenantId = null, CancellationToken cancellationToken = default)
{
var dbContext = await GetDbContextAsync();
var userMarkedItemQueryable = await GetMongoQueryableAsync(GetCancellationToken(cancellationToken));
var userMarkedItemQueryable = await GetQueryableAsync(GetCancellationToken(cancellationToken));
var resultQueryable = userMarkedItemQueryable
.Where(x => x.CreatorId == userId

8
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Pages/MongoPageRepository.cs

@ -26,7 +26,7 @@ public class MongoPageRepository : MongoDbRepository<ICmsKitMongoDbContext, Page
{
var cancellation = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellation))
return await (await GetQueryableAsync(cancellation))
.WhereIf(
!filter.IsNullOrWhiteSpace(),
u =>
@ -43,7 +43,7 @@ public class MongoPageRepository : MongoDbRepository<ICmsKitMongoDbContext, Page
{
var cancellation = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellation))
return await (await GetQueryableAsync(cancellation))
.WhereIf(
!filter.IsNullOrWhiteSpace(),
u => u.Title.ToLower().Contains(filter) || u.Slug.Contains(filter))
@ -67,7 +67,7 @@ public class MongoPageRepository : MongoDbRepository<ICmsKitMongoDbContext, Page
public virtual async Task<bool> ExistsAsync([NotNull] string slug, CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(slug, nameof(slug));
return await (await GetMongoQueryableAsync(cancellationToken)).AnyAsync(x => x.Slug == slug,
return await (await GetQueryableAsync(cancellationToken)).AnyAsync(x => x.Slug == slug,
GetCancellationToken(cancellationToken));
}
@ -78,7 +78,7 @@ public class MongoPageRepository : MongoDbRepository<ICmsKitMongoDbContext, Page
public async Task<string?> FindTitleAsync(Guid pageId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.Id == pageId).Select(x => x.Title)
return await (await GetQueryableAsync(cancellationToken)).Where(x => x.Id == pageId).Select(x => x.Title)
.FirstOrDefaultAsync(cancellationToken);
}
}

4
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Ratings/MongoRatingRepository.cs

@ -25,7 +25,7 @@ public class MongoRatingRepository : MongoDbRepository<ICmsKitMongoDbContext, Ra
Check.NotNullOrWhiteSpace(entityType, nameof(entityType));
Check.NotNullOrWhiteSpace(entityId, nameof(entityId));
var rating = await (await GetMongoQueryableAsync(cancellationToken))
var rating = await (await GetQueryableAsync(cancellationToken))
.FirstOrDefaultAsync(r => r.EntityType == entityType && r.EntityId == entityId && r.CreatorId == userId,
GetCancellationToken(cancellationToken));
@ -39,7 +39,7 @@ public class MongoRatingRepository : MongoDbRepository<ICmsKitMongoDbContext, Ra
Check.NotNullOrWhiteSpace(entityId, nameof(entityId));
var query = (
from rating in (await GetMongoQueryableAsync(cancellationToken))
from rating in (await GetQueryableAsync(cancellationToken))
where rating.EntityType == entityType && rating.EntityId == entityId
group rating by rating.StarCount
into g

6
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Reactions/MongoUserReactionRepository.cs

@ -29,7 +29,7 @@ public class MongoUserReactionRepository : MongoDbRepository<ICmsKitMongoDbConte
Check.NotNullOrWhiteSpace(entityId, nameof(entityId));
Check.NotNullOrWhiteSpace(reactionName, nameof(reactionName));
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(x =>
x.CreatorId == userId &&
x.EntityType == entityType &&
@ -47,7 +47,7 @@ public class MongoUserReactionRepository : MongoDbRepository<ICmsKitMongoDbConte
Check.NotNullOrWhiteSpace(entityType, nameof(entityType));
Check.NotNullOrWhiteSpace(entityId, nameof(entityId));
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(x =>
x.CreatorId == userId &&
x.EntityType == entityType &&
@ -63,7 +63,7 @@ public class MongoUserReactionRepository : MongoDbRepository<ICmsKitMongoDbConte
Check.NotNullOrWhiteSpace(entityType, nameof(entityType));
Check.NotNullOrWhiteSpace(entityId, nameof(entityId));
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(x =>
x.EntityType == entityType &&
x.EntityId == entityId)

2
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoEntityTagRepository.cs

@ -67,7 +67,7 @@ public class MongoEntityTagRepository : MongoDbRepository<ICmsKitMongoDbContext,
CancellationToken cancellationToken = default)
{
var dbContext = await GetDbContextAsync();
var entityTagQueryable = await GetMongoQueryableAsync(GetCancellationToken(cancellationToken));
var entityTagQueryable = await GetQueryableAsync(GetCancellationToken(cancellationToken));
var tagQueryable = dbContext.Tags.AsQueryable();
var resultQueryable = entityTagQueryable

12
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs

@ -29,7 +29,7 @@ public class MongoTagRepository : MongoDbRepository<ICmsKitMongoDbContext, Volo.
Check.NotNullOrEmpty(entityType, nameof(entityType));
Check.NotNullOrEmpty(name, nameof(name));
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.AnyAsync(x =>
x.EntityType == entityType &&
x.Name == name,
@ -69,12 +69,12 @@ public class MongoTagRepository : MongoDbRepository<ICmsKitMongoDbContext, Volo.
Check.NotNullOrEmpty(entityType, nameof(entityType));
Check.NotNullOrEmpty(entityId, nameof(entityId));
var entityTagIds = await (await GetMongoQueryableAsync<EntityTag>(cancellationToken))
var entityTagIds = await (await GetQueryableAsync<EntityTag>(cancellationToken))
.Where(q => q.EntityId == entityId)
.Select(q => q.TagId)
.ToListAsync(cancellationToken: GetCancellationToken(cancellationToken));
var query = (await GetMongoQueryableAsync(cancellationToken))
var query = (await GetQueryableAsync(cancellationToken))
.Where(x =>
x.EntityType == entityType &&
entityTagIds.Contains(x.Id));
@ -86,14 +86,14 @@ public class MongoTagRepository : MongoDbRepository<ICmsKitMongoDbContext, Volo.
public virtual async Task<List<PopularTag>> GetPopularTagsAsync(string entityType, int maxCount, CancellationToken cancellationToken = default)
{
var tags = await (await GetMongoQueryableAsync(cancellationToken))
var tags = await (await GetQueryableAsync(cancellationToken))
.Where(x => x.EntityType == entityType)
.Select(x => new { x.Id, x.Name })
.ToListAsync(cancellationToken: GetCancellationToken(cancellationToken));
var tagIds = tags.Select(x => x.Id);
var entityTagCounts = await (await GetMongoQueryableAsync<EntityTag>(cancellationToken))
var entityTagCounts = await (await GetQueryableAsync<EntityTag>(cancellationToken))
.Where(q => tagIds.Contains(q.TagId))
.GroupBy(q => q.TagId)
.Select(q => new { TagId = q.Key, Count = q.Count() })
@ -127,7 +127,7 @@ public class MongoTagRepository : MongoDbRepository<ICmsKitMongoDbContext, Volo.
private async Task<IQueryable<Tag>> GetQueryableByFilterAsync(string filter, CancellationToken cancellationToken = default)
{
var mongoQueryable = await GetMongoQueryableAsync(cancellationToken: cancellationToken);
var mongoQueryable = await GetQueryableAsync(cancellationToken: cancellationToken);
if (!filter.IsNullOrWhiteSpace())
{

22
modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs

@ -22,7 +22,7 @@ namespace Volo.Docs.Documents
public virtual async Task<List<DocumentWithoutDetails>> GetListWithoutDetailsByProjectId(Guid projectId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(d => d.ProjectId == projectId)
.Select(x => new DocumentWithoutDetails
{
@ -37,7 +37,7 @@ namespace Volo.Docs.Documents
public virtual async Task<List<DocumentInfo>> GetUniqueListDocumentInfoAsync(CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Select(x=> new DocumentInfo {
ProjectId = x.ProjectId,
Version = x.Version,
@ -51,13 +51,13 @@ namespace Volo.Docs.Documents
public virtual async Task<List<Document>> GetListByProjectId(Guid projectId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).Where(d => d.ProjectId == projectId).ToListAsync(GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync(cancellationToken)).Where(d => d.ProjectId == projectId).ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<Document>> GetUniqueDocumentsByProjectIdPagedAsync(Guid projectId, int skipCount, int maxResultCount,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(d => d.ProjectId == projectId)
.OrderBy(x => x.LastCachedTime)
.GroupBy(x => new { x.Name, x.LanguageCode, x.Version })
@ -69,7 +69,7 @@ namespace Volo.Docs.Documents
public virtual async Task<long> GetUniqueDocumentCountByProjectIdAsync(Guid projectId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).Where(d => d.ProjectId == projectId)
return await (await GetQueryableAsync(cancellationToken)).Where(d => d.ProjectId == projectId)
.GroupBy(x => new { x.Name, x.LanguageCode, x.Version })
.LongCountAsync(GetCancellationToken(cancellationToken));
}
@ -89,7 +89,7 @@ namespace Volo.Docs.Documents
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).FirstOrDefaultAsync(x =>
return await (await GetQueryableAsync(cancellationToken)).FirstOrDefaultAsync(x =>
x.ProjectId == projectId &&
x.Name == name &&
x.LanguageCode == languageCode &&
@ -100,7 +100,7 @@ namespace Volo.Docs.Documents
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).FirstOrDefaultAsync(x => x.ProjectId == projectId &&
return await (await GetQueryableAsync(cancellationToken)).FirstOrDefaultAsync(x => x.ProjectId == projectId &&
possibleNames.Contains(x.Name) &&
x.LanguageCode == languageCode &&
x.Version == version, GetCancellationToken(cancellationToken));
@ -115,7 +115,7 @@ namespace Volo.Docs.Documents
public virtual async Task<List<Document>> GetListAsync(Guid? projectId, string version, string name, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(version != null, x => x.Version == version)
.WhereIf(name != null, x => x.Name == name)
.WhereIf(projectId.HasValue, x => x.ProjectId == projectId)
@ -144,7 +144,7 @@ namespace Volo.Docs.Documents
{
return await
(await ApplyFilterForGetAll(
await GetMongoQueryableAsync(cancellationToken),
await GetQueryableAsync(cancellationToken),
projectId: projectId,
name: name,
version: version,
@ -185,7 +185,7 @@ namespace Volo.Docs.Documents
{
return await
(await ApplyFilterForGetAll(
await GetMongoQueryableAsync(cancellationToken),
await GetQueryableAsync(cancellationToken),
projectId: projectId,
name: name,
version: version,
@ -207,7 +207,7 @@ namespace Volo.Docs.Documents
public virtual async Task<Document> GetAsync(Guid id, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.Id == id).SingleAsync(GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync(cancellationToken)).Where(x => x.Id == id).SingleAsync(GetCancellationToken(cancellationToken));
}
protected virtual async Task<IQueryable<DocumentWithoutContent>> ApplyFilterForGetAll(

8
modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Projects/MongoProjectRepository.cs

@ -22,7 +22,7 @@ namespace Volo.Docs.Projects
public virtual async Task<List<Project>> GetListAsync(string sorting, int maxResultCount, int skipCount, CancellationToken cancellationToken = default)
{
var projects = await (await GetMongoQueryableAsync(cancellationToken)).OrderBy(sorting.IsNullOrEmpty() ? "Id desc" : sorting).PageBy(skipCount, maxResultCount)
var projects = await (await GetQueryableAsync(cancellationToken)).OrderBy(sorting.IsNullOrEmpty() ? "Id desc" : sorting).PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
return projects;
@ -30,7 +30,7 @@ namespace Volo.Docs.Projects
public virtual async Task<List<ProjectWithoutDetails>> GetListWithoutDetailsAsync(CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Select(x=> new ProjectWithoutDetails {
Id = x.Id,
Name = x.Name,
@ -43,7 +43,7 @@ namespace Volo.Docs.Projects
{
var normalizeShortName = NormalizeShortName(shortName);
var project = await (await GetMongoQueryableAsync(cancellationToken)).FirstOrDefaultAsync(p => p.ShortName == normalizeShortName, GetCancellationToken(cancellationToken));
var project = await (await GetQueryableAsync(cancellationToken)).FirstOrDefaultAsync(p => p.ShortName == normalizeShortName, GetCancellationToken(cancellationToken));
if (project == null)
{
@ -57,7 +57,7 @@ namespace Volo.Docs.Projects
{
var normalizeShortName = NormalizeShortName(shortName);
return await (await GetMongoQueryableAsync(cancellationToken)).AnyAsync(x => x.ShortName == normalizeShortName, GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync(cancellationToken)).AnyAsync(x => x.ShortName == normalizeShortName, GetCancellationToken(cancellationToken));
}
private string NormalizeShortName(string shortName)

2
modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/MongoFeatureDefinitionRecordRepository.cs

@ -21,7 +21,7 @@ public class MongoFeatureDefinitionRecordRepository :
public virtual async Task<FeatureDefinitionRecord> FindByNameAsync(string name, CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(
s => s.Name == name,

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

@ -27,7 +27,7 @@ public class MongoFeatureValueRepository :
string providerKey,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey, GetCancellationToken(cancellationToken));
}
@ -38,7 +38,7 @@ public class MongoFeatureValueRepository :
string providerKey,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey).ToListAsync(GetCancellationToken(cancellationToken));
}
@ -47,7 +47,7 @@ public class MongoFeatureValueRepository :
string providerKey,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(s => s.ProviderName == providerName && s.ProviderKey == providerKey)
.ToListAsync(GetCancellationToken(cancellationToken));
}

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

@ -24,13 +24,13 @@ public class MongoIdentityClaimTypeRepository : MongoDbRepository<IAbpIdentityMo
{
if (ignoredId == null)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(ct => ct.Name == name)
.AnyAsync(GetCancellationToken(cancellationToken));
}
else
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(ct => ct.Id != ignoredId && ct.Name == name)
.AnyAsync(GetCancellationToken(cancellationToken));
}
@ -43,7 +43,7 @@ public class MongoIdentityClaimTypeRepository : MongoDbRepository<IAbpIdentityMo
string filter,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(
!filter.IsNullOrWhiteSpace(),
u =>
@ -58,7 +58,7 @@ public class MongoIdentityClaimTypeRepository : MongoDbRepository<IAbpIdentityMo
string filter = null,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(
!filter.IsNullOrWhiteSpace(),
u =>
@ -69,7 +69,7 @@ public class MongoIdentityClaimTypeRepository : MongoDbRepository<IAbpIdentityMo
public virtual async Task<List<IdentityClaimType>> GetListByNamesAsync(IEnumerable<string> names, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(x => names.Contains(x.Name))
.ToListAsync(GetCancellationToken(cancellationToken));
}

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

@ -18,7 +18,7 @@ public class MongoIdentityLinkUserRepository : MongoDbRepository<IAbpIdentityMon
public virtual async Task<IdentityLinkUser> FindAsync(IdentityLinkUserInfo sourceLinkUserInfo, IdentityLinkUserInfo targetLinkUserInfo, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.OrderBy(x => x.Id).FirstOrDefaultAsync(x =>
x.SourceUserId == sourceLinkUserInfo.UserId && x.SourceTenantId == sourceLinkUserInfo.TenantId &&
x.TargetUserId == targetLinkUserInfo.UserId && x.TargetTenantId == targetLinkUserInfo.TenantId ||
@ -30,7 +30,7 @@ public class MongoIdentityLinkUserRepository : MongoDbRepository<IAbpIdentityMon
public virtual async Task<List<IdentityLinkUser>> GetListAsync(IdentityLinkUserInfo linkUserInfo, List<IdentityLinkUserInfo> excludes = null,
CancellationToken cancellationToken = default)
{
var query = (await GetMongoQueryableAsync(cancellationToken)).Where(x =>
var query = (await GetQueryableAsync(cancellationToken)).Where(x =>
x.SourceUserId == linkUserInfo.UserId && x.SourceTenantId == linkUserInfo.TenantId ||
x.TargetUserId == linkUserInfo.UserId && x.TargetTenantId == linkUserInfo.TenantId);
@ -49,7 +49,7 @@ public class MongoIdentityLinkUserRepository : MongoDbRepository<IAbpIdentityMon
public virtual async Task DeleteAsync(IdentityLinkUserInfo linkUserInfo, CancellationToken cancellationToken = default)
{
var linkUsers = await (await GetMongoQueryableAsync(cancellationToken)).Where(x =>
var linkUsers = await (await GetQueryableAsync(cancellationToken)).Where(x =>
x.SourceUserId == linkUserInfo.UserId && x.SourceTenantId == linkUserInfo.TenantId ||
x.TargetUserId == linkUserInfo.UserId && x.TargetTenantId == linkUserInfo.TenantId)
.ToListAsync(cancellationToken: GetCancellationToken(cancellationToken));

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

@ -23,7 +23,7 @@ public class MongoIdentityRoleRepository : MongoDbRepository<IAbpIdentityMongoDb
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(r => r.NormalizedName == normalizedRoleName, GetCancellationToken(cancellationToken));
}
@ -38,7 +38,7 @@ public class MongoIdentityRoleRepository : MongoDbRepository<IAbpIdentityMongoDb
{
var roles = await GetListInternalAsync(sorting, maxResultCount, skipCount, filter, includeDetails, cancellationToken: cancellationToken);
var roleIds = roles.Select(x => x.Id).ToList();
var userCount = await (await GetMongoQueryableAsync<IdentityUser>(cancellationToken))
var userCount = await (await GetQueryableAsync<IdentityUser>(cancellationToken))
.Where(user => user.Roles.Any(role => roleIds.Contains(role.RoleId)))
.SelectMany(user => user.Roles)
.GroupBy(userRole => userRole.RoleId)
@ -73,7 +73,7 @@ public class MongoIdentityRoleRepository : MongoDbRepository<IAbpIdentityMongoDb
IEnumerable<Guid> ids,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(t => ids.Contains(t.Id))
.ToListAsync(GetCancellationToken(cancellationToken));
}
@ -82,7 +82,7 @@ public class MongoIdentityRoleRepository : MongoDbRepository<IAbpIdentityMongoDb
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(r => r.IsDefault)
.ToListAsync(GetCancellationToken(cancellationToken));
}
@ -91,7 +91,7 @@ public class MongoIdentityRoleRepository : MongoDbRepository<IAbpIdentityMongoDb
string filter = null,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrWhiteSpace(),
x => x.Name.Contains(filter) ||
x.NormalizedName.Contains(filter))
@ -100,7 +100,7 @@ public class MongoIdentityRoleRepository : MongoDbRepository<IAbpIdentityMongoDb
public virtual async Task RemoveClaimFromAllRolesAsync(string claimType, bool autoSave = false, CancellationToken cancellationToken = default)
{
var roles = await (await GetMongoQueryableAsync(cancellationToken))
var roles = await (await GetQueryableAsync(cancellationToken))
.Where(r => r.Claims.Any(c => c.ClaimType == claimType))
.ToListAsync(GetCancellationToken(cancellationToken));
@ -120,7 +120,7 @@ public class MongoIdentityRoleRepository : MongoDbRepository<IAbpIdentityMongoDb
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrWhiteSpace(),
x => x.Name.Contains(filter) ||
x.NormalizedName.Contains(filter))

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

@ -89,7 +89,7 @@ public class MongoIdentitySecurityLogRepository :
public virtual async Task<IdentitySecurityLog> GetByUserIdAsync(Guid id, Guid userId, bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).OrderBy(x => x.Id).FirstOrDefaultAsync(x => x.Id == id && x.UserId == userId,
return await (await GetQueryableAsync(cancellationToken)).OrderBy(x => x.Id).FirstOrDefaultAsync(x => x.Id == id && x.UserId == userId,
GetCancellationToken(cancellationToken));
}
@ -106,7 +106,7 @@ public class MongoIdentitySecurityLogRepository :
string clientIpAddress = null,
CancellationToken cancellationToken = default)
{
return (await GetMongoQueryableAsync(cancellationToken))
return (await GetQueryableAsync(cancellationToken))
.WhereIf(startTime.HasValue, securityLog => securityLog.CreationTime >= startTime.Value)
.WhereIf(endTime.HasValue, securityLog => securityLog.CreationTime < endTime.Value.AddDays(1).Date)
.WhereIf(!applicationName.IsNullOrWhiteSpace(), securityLog => securityLog.ApplicationName == applicationName)

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

@ -23,7 +23,7 @@ public class MongoIdentitySessionRepository : MongoDbRepository<IAbpIdentityMong
public virtual async Task<IdentitySession> FindAsync(string sessionId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
return await (await GetQueryableAsync(GetCancellationToken(cancellationToken)))
.FirstOrDefaultAsync(x => x.SessionId == sessionId, GetCancellationToken(cancellationToken));
}
@ -40,13 +40,13 @@ public class MongoIdentitySessionRepository : MongoDbRepository<IAbpIdentityMong
public virtual async Task<bool> ExistAsync(Guid id, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
return await (await GetQueryableAsync(GetCancellationToken(cancellationToken)))
.AnyAsync(x => x.Id == id, GetCancellationToken(cancellationToken));
}
public virtual async Task<bool> ExistAsync(string sessionId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
return await (await GetQueryableAsync(GetCancellationToken(cancellationToken)))
.AnyAsync(x => x.SessionId == sessionId, GetCancellationToken(cancellationToken));
}
@ -59,7 +59,7 @@ public class MongoIdentitySessionRepository : MongoDbRepository<IAbpIdentityMong
string clientId = null,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
return await (await GetQueryableAsync(GetCancellationToken(cancellationToken)))
.WhereIf(userId.HasValue, x => x.UserId == userId)
.WhereIf(!device.IsNullOrWhiteSpace(), x => x.Device == device)
.WhereIf(!clientId.IsNullOrWhiteSpace(), x => x.ClientId == clientId)
@ -74,7 +74,7 @@ public class MongoIdentitySessionRepository : MongoDbRepository<IAbpIdentityMong
string clientId = null,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
return await (await GetQueryableAsync(GetCancellationToken(cancellationToken)))
.WhereIf(userId.HasValue, x => x.UserId == userId)
.WhereIf(!device.IsNullOrWhiteSpace(), x => x.Device == device)
.WhereIf(!clientId.IsNullOrWhiteSpace(), x => x.ClientId == clientId)

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

@ -24,7 +24,7 @@ public class MongoIdentityUserDelegationRepository : MongoDbRepository<IAbpIdent
public virtual async Task<List<IdentityUserDelegation>> GetListAsync(Guid? sourceUserId, Guid? targetUserId,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(sourceUserId.HasValue, x => x.SourceUserId == sourceUserId)
.WhereIf(targetUserId.HasValue, x => x.TargetUserId == targetUserId)
.ToListAsync(cancellationToken: cancellationToken);
@ -32,7 +32,7 @@ public class MongoIdentityUserDelegationRepository : MongoDbRepository<IAbpIdent
public virtual async Task<List<IdentityUserDelegation>> GetActiveDelegationsAsync(Guid targetUserId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(x => x.TargetUserId == targetUserId)
.Where(x => x.StartTime <= Clock.Now && x.EndTime >= Clock.Now)
.ToListAsync(cancellationToken: cancellationToken);
@ -40,7 +40,7 @@ public class MongoIdentityUserDelegationRepository : MongoDbRepository<IAbpIdent
public virtual async Task<IdentityUserDelegation> FindActiveDelegationByIdAsync(Guid id, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.FirstOrDefaultAsync(x =>
x.Id == id &&
x.StartTime <= Clock.Now &&

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

@ -25,7 +25,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(
u => u.NormalizedUserName == normalizedUserName,
@ -43,13 +43,13 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
.Select(r => r.OrganizationUnitId)
.ToArray();
var organizationUnits = await (await GetMongoQueryableAsync<OrganizationUnit>(cancellationToken))
var organizationUnits = await (await GetQueryableAsync<OrganizationUnit>(cancellationToken))
.Where(ou => organizationUnitIds.Contains(ou.Id))
.ToListAsync(cancellationToken: cancellationToken);
var orgUnitRoleIds = organizationUnits.SelectMany(x => x.Roles.Select(r => r.RoleId)).ToArray();
var roleIds = user.Roles.Select(r => r.RoleId).ToArray();
var allRoleIds = orgUnitRoleIds.Union(roleIds);
return await (await GetMongoQueryableAsync<IdentityRole>(cancellationToken)).Where(r => allRoleIds.Contains(r.Id)).Select(r => r.Name).ToListAsync(cancellationToken);
return await (await GetQueryableAsync<IdentityRole>(cancellationToken)).Where(r => allRoleIds.Contains(r.Id)).Select(r => r.Name).ToListAsync(cancellationToken);
}
public virtual async Task<List<string>> GetRoleNamesInOrganizationUnitAsync(
@ -63,13 +63,13 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
.Select(r => r.OrganizationUnitId)
.ToArray();
var organizationUnits = await (await GetMongoQueryableAsync<OrganizationUnit>(cancellationToken))
var organizationUnits = await (await GetQueryableAsync<OrganizationUnit>(cancellationToken))
.Where(ou => organizationUnitIds.Contains(ou.Id))
.ToListAsync(cancellationToken: cancellationToken);
var roleIds = organizationUnits.SelectMany(x => x.Roles.Select(r => r.RoleId)).ToArray();
var queryable = await GetMongoQueryableAsync<IdentityRole>(cancellationToken);
var queryable = await GetQueryableAsync<IdentityRole>(cancellationToken);
return await queryable
.Where(r => roleIds.Contains(r.Id))
@ -83,7 +83,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(u => u.Logins.Any(login => login.LoginProvider == loginProvider && login.ProviderKey == providerKey))
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
@ -94,7 +94,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.OrderBy(x => x.Id).FirstOrDefaultAsync(u => u.NormalizedEmail == normalizedEmail, GetCancellationToken(cancellationToken));
}
@ -103,14 +103,14 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(u => u.Claims.Any(c => c.ClaimType == claim.Type && c.ClaimValue == claim.Value))
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task RemoveClaimFromAllUsersAsync(string claimType, bool autoSave, CancellationToken cancellationToken = default)
{
var users = await (await GetMongoQueryableAsync(cancellationToken))
var users = await (await GetQueryableAsync(cancellationToken))
.Where(u => u.Claims.Any(c => c.ClaimType == claimType))
.ToListAsync(GetCancellationToken(cancellationToken));
@ -129,7 +129,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
{
cancellationToken = GetCancellationToken(cancellationToken);
var queryable = await GetMongoQueryableAsync<IdentityRole>(cancellationToken);
var queryable = await GetQueryableAsync<IdentityRole>(cancellationToken);
var role = await queryable
.Where(x => x.NormalizedName == normalizedRoleName)
@ -141,7 +141,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
return new List<IdentityUser>();
}
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(u => u.Roles.Any(r => r.RoleId == role.Id))
.ToListAsync(cancellationToken);
}
@ -150,7 +150,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(u => u.Roles.Any(r => r.RoleId == roleId))
.Select(x => x.Id)
.ToListAsync(cancellationToken);
@ -216,13 +216,13 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
.Select(r => r.OrganizationUnitId)
.ToArray();
var organizationUnits = await (await GetMongoQueryableAsync<OrganizationUnit>(cancellationToken))
var organizationUnits = await (await GetQueryableAsync<OrganizationUnit>(cancellationToken))
.Where(ou => organizationUnitIds.Contains(ou.Id))
.ToListAsync(cancellationToken: cancellationToken);
var orgUnitRoleIds = organizationUnits.SelectMany(x => x.Roles.Select(r => r.RoleId)).ToArray();
var roleIds = user.Roles.Select(r => r.RoleId).ToArray();
var allRoleIds = orgUnitRoleIds.Union(roleIds);
return await (await GetMongoQueryableAsync<IdentityRole>(cancellationToken)).Where(r => allRoleIds.Contains(r.Id)).ToListAsync(cancellationToken);
return await (await GetQueryableAsync<IdentityRole>(cancellationToken)).Where(r => allRoleIds.Contains(r.Id)).ToListAsync(cancellationToken);
}
public virtual async Task<List<OrganizationUnit>> GetOrganizationUnitsAsync(
@ -234,7 +234,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
var user = await GetAsync(id, cancellationToken: cancellationToken);
var organizationUnitIds = user.OrganizationUnits.Select(r => r.OrganizationUnitId);
return await (await GetMongoQueryableAsync<OrganizationUnit>(cancellationToken))
return await (await GetQueryableAsync<OrganizationUnit>(cancellationToken))
.Where(ou => organizationUnitIds.Contains(ou.Id))
.ToListAsync(cancellationToken);
}
@ -285,7 +285,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
Guid organizationUnitId,
CancellationToken cancellationToken = default)
{
var result = await (await GetMongoQueryableAsync(cancellationToken))
var result = await (await GetQueryableAsync(cancellationToken))
.Where(u => u.OrganizationUnits.Any(uou => uou.OrganizationUnitId == organizationUnitId))
.ToListAsync(GetCancellationToken(cancellationToken));
return result;
@ -295,7 +295,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
List<Guid> organizationUnitIds,
CancellationToken cancellationToken = default)
{
var result = await (await GetMongoQueryableAsync(cancellationToken))
var result = await (await GetQueryableAsync(cancellationToken))
.Where(u => u.OrganizationUnits.Any(uou => organizationUnitIds.Contains(uou.OrganizationUnitId)))
.ToListAsync(GetCancellationToken(cancellationToken));
return result;
@ -307,12 +307,12 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
{
cancellationToken = GetCancellationToken(cancellationToken);
var organizationUnitIds = await (await GetMongoQueryableAsync<OrganizationUnit>(cancellationToken))
var organizationUnitIds = await (await GetQueryableAsync<OrganizationUnit>(cancellationToken))
.Where(ou => ou.Code.StartsWith(code))
.Select(ou => ou.Id)
.ToListAsync(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(u => u.OrganizationUnits.Any(uou => organizationUnitIds.Contains(uou.OrganizationUnitId)))
.ToListAsync(cancellationToken);
}
@ -323,7 +323,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.FirstOrDefaultAsync(
u => u.TenantId == tenantId && u.UserName == userName,
GetCancellationToken(cancellationToken)
@ -332,14 +332,14 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
public virtual async Task<List<IdentityUser>> GetListByIdsAsync(IEnumerable<Guid> ids, bool includeDetails = false, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(x => ids.Contains(x.Id))
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task UpdateRoleAsync(Guid sourceRoleId, Guid? targetRoleId, CancellationToken cancellationToken = default)
{
var users = await (await GetMongoQueryableAsync(cancellationToken))
var users = await (await GetQueryableAsync(cancellationToken))
.Where(x => x.Roles.Any(r => r.RoleId == sourceRoleId))
.ToListAsync(GetCancellationToken(cancellationToken));
@ -357,7 +357,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
public virtual async Task UpdateOrganizationAsync(Guid sourceOrganizationId, Guid? targetOrganizationId, CancellationToken cancellationToken = default)
{
var users = await (await GetMongoQueryableAsync(cancellationToken))
var users = await (await GetQueryableAsync(cancellationToken))
.Where(x => x.OrganizationUnits.Any(r => r.OrganizationUnitId == sourceOrganizationId))
.ToListAsync(GetCancellationToken(cancellationToken));
@ -389,7 +389,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
var organizationUnitIds = userAndOrganizationUnitIds.SelectMany(x => x.Value);
var roleIds = userAndRoleIds.SelectMany(x => x.Value);
var organizationUnitAndRoleIds = await (await GetMongoQueryableAsync<OrganizationUnit>(cancellationToken)).Where(ou => organizationUnitIds.Contains(ou.Id))
var organizationUnitAndRoleIds = await (await GetQueryableAsync<OrganizationUnit>(cancellationToken)).Where(ou => organizationUnitIds.Contains(ou.Id))
.Select(userOrganizationUnit => new
{
userOrganizationUnit.Id,
@ -398,7 +398,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
var allOrganizationUnitRoleIds = organizationUnitAndRoleIds.SelectMany(x => x.Roles.Select(r => r.RoleId)).ToList();
var allRoleIds = roleIds.Union(allOrganizationUnitRoleIds);
var roles = await (await GetMongoQueryableAsync<IdentityRole>(cancellationToken)).Where(r => allRoleIds.Contains(r.Id)).Select(r => new{ r.Id, r.Name }).ToListAsync(cancellationToken);
var roles = await (await GetQueryableAsync<IdentityRole>(cancellationToken)).Where(r => allRoleIds.Contains(r.Id)).Select(r => new{ r.Id, r.Name }).ToListAsync(cancellationToken);
var userRoles = userAndRoleIds.ToDictionary(x => x.Key, x => roles.Where(r => x.Value.Contains(r.Id)).Select(r => r.Name).ToArray());
var result = userRoles.Select(x => new IdentityUserIdWithRoleNames { Id = x.Key, RoleNames = x.Value }).ToList();
@ -441,11 +441,11 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
CancellationToken cancellationToken = default)
{
var upperFilter = filter?.ToUpperInvariant();
var query = await GetMongoQueryableAsync(cancellationToken);
var query = await GetQueryableAsync(cancellationToken);
if (roleId.HasValue)
{
var organizationUnitIds = (await GetMongoQueryableAsync<OrganizationUnit>(cancellationToken))
var organizationUnitIds = (await GetQueryableAsync<OrganizationUnit>(cancellationToken))
.Where(ou => ou.Roles.Any(r => r.RoleId == roleId.Value))
.Select(userOrganizationUnit => userOrganizationUnit.Id)
.ToArray();

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

@ -27,7 +27,7 @@ public class MongoOrganizationUnitRepository
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(ou => ou.ParentId == parentId)
.ToListAsync(GetCancellationToken(cancellationToken));
}
@ -38,7 +38,7 @@ public class MongoOrganizationUnitRepository
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(ou => ou.Code.StartsWith(code) && ou.Id != parentId)
.ToListAsync(GetCancellationToken(cancellationToken));
}
@ -48,7 +48,7 @@ public class MongoOrganizationUnitRepository
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(t => ids.Contains(t.Id))
.ToListAsync(GetCancellationToken(cancellationToken));
}
@ -58,7 +58,7 @@ public class MongoOrganizationUnitRepository
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(x => x.Roles.Any(r => r.RoleId == roleId))
.ToListAsync(GetCancellationToken(cancellationToken));
}
@ -70,7 +70,7 @@ public class MongoOrganizationUnitRepository
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.OrderBy(sorting.IsNullOrEmpty() ? nameof(OrganizationUnit.CreationTime) + " desc" : sorting)
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
@ -81,7 +81,7 @@ public class MongoOrganizationUnitRepository
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(
ou => ou.DisplayName == displayName,
@ -99,7 +99,7 @@ public class MongoOrganizationUnitRepository
{
var roleIds = organizationUnit.Roles.Select(r => r.RoleId).ToArray();
return await (await GetMongoQueryableAsync<IdentityRole>(cancellationToken))
return await (await GetQueryableAsync<IdentityRole>(cancellationToken))
.Where(r => roleIds.Contains(r.Id))
.OrderBy(sorting.IsNullOrEmpty() ? nameof(IdentityRole.Name) : sorting)
.PageBy(skipCount, maxResultCount)
@ -114,13 +114,13 @@ public class MongoOrganizationUnitRepository
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
var organizationUnits = await (await GetMongoQueryableAsync(cancellationToken))
var organizationUnits = await (await GetQueryableAsync(cancellationToken))
.Where(ou => organizationUnitIds.Contains(ou.Id))
.ToListAsync(GetCancellationToken(cancellationToken));
var roleIds = organizationUnits.SelectMany(ou => ou.Roles.Select(r => r.RoleId)).ToArray();
return await (await GetMongoQueryableAsync<IdentityRole>(cancellationToken))
return await (await GetQueryableAsync<IdentityRole>(cancellationToken))
.Where(r => roleIds.Contains(r.Id))
.OrderBy(sorting.IsNullOrEmpty() ? nameof(IdentityRole.Name) : sorting)
.PageBy(skipCount, maxResultCount)
@ -133,7 +133,7 @@ public class MongoOrganizationUnitRepository
{
var roleIds = organizationUnit.Roles.Select(r => r.RoleId).ToArray();
return await (await GetMongoQueryableAsync<IdentityRole>(cancellationToken)).Where(r => roleIds.Contains(r.Id)).CountAsync(GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync<IdentityRole>(cancellationToken)).Where(r => roleIds.Contains(r.Id)).CountAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<IdentityRole>> GetUnaddedRolesAsync(
@ -147,7 +147,7 @@ public class MongoOrganizationUnitRepository
{
var roleIds = organizationUnit.Roles.Select(r => r.RoleId).ToArray();
return await (await GetMongoQueryableAsync<IdentityRole>(cancellationToken))
return await (await GetQueryableAsync<IdentityRole>(cancellationToken))
.Where(r => !roleIds.Contains(r.Id))
.WhereIf(!filter.IsNullOrWhiteSpace(), r => r.Name.Contains(filter))
.OrderBy(sorting.IsNullOrEmpty() ? nameof(IdentityRole.Name) : sorting)
@ -162,7 +162,7 @@ public class MongoOrganizationUnitRepository
{
var roleIds = organizationUnit.Roles.Select(r => r.RoleId).ToArray();
return await (await GetMongoQueryableAsync<IdentityRole>(cancellationToken))
return await (await GetQueryableAsync<IdentityRole>(cancellationToken))
.Where(r => !roleIds.Contains(r.Id))
.WhereIf(!filter.IsNullOrWhiteSpace(), r => r.Name.Contains(filter))
.CountAsync(GetCancellationToken(cancellationToken));
@ -188,7 +188,7 @@ public class MongoOrganizationUnitRepository
public virtual async Task<List<Guid>> GetMemberIdsAsync(Guid id, CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync<IdentityUser>(cancellationToken))
return await (await GetQueryableAsync<IdentityUser>(cancellationToken))
.Where(u => u.OrganizationUnits.Any(uou => uou.OrganizationUnitId == id)).Select(x => x.Id)
.ToListAsync(cancellationToken);
}
@ -213,7 +213,7 @@ public class MongoOrganizationUnitRepository
CancellationToken cancellationToken = default)
{
return await
(await GetMongoQueryableAsync<IdentityUser>(cancellationToken))
(await GetQueryableAsync<IdentityUser>(cancellationToken))
.Where(u => !u.OrganizationUnits.Any(uou => uou.OrganizationUnitId == organizationUnit.Id))
.WhereIf(
!filter.IsNullOrWhiteSpace(),
@ -230,7 +230,7 @@ public class MongoOrganizationUnitRepository
public virtual async Task<int> GetUnaddedUsersCountAsync(OrganizationUnit organizationUnit, string filter = null,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync<IdentityUser>(cancellationToken))
return await (await GetQueryableAsync<IdentityUser>(cancellationToken))
.Where(u => !u.OrganizationUnits.Any(uou => uou.OrganizationUnitId == organizationUnit.Id))
.WhereIf(
!filter.IsNullOrWhiteSpace(),
@ -251,7 +251,7 @@ public class MongoOrganizationUnitRepository
public virtual async Task RemoveAllMembersAsync(OrganizationUnit organizationUnit, CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
var userQueryable = await GetMongoQueryableAsync<IdentityUser>(cancellationToken);
var userQueryable = await GetQueryableAsync<IdentityUser>(cancellationToken);
var dbContext = await GetDbContextAsync(cancellationToken);
var users = await userQueryable
.Where(u => u.OrganizationUnits.Any(uou => uou.OrganizationUnitId == organizationUnit.Id))
@ -269,7 +269,7 @@ public class MongoOrganizationUnitRepository
string filter = null,
CancellationToken cancellationToken = default)
{
return (await GetMongoQueryableAsync<IdentityUser>(cancellationToken))
return (await GetQueryableAsync<IdentityUser>(cancellationToken))
.Where(u => u.OrganizationUnits.Any(uou => uou.OrganizationUnitId == organizationUnit.Id))
.WhereIf(
!filter.IsNullOrWhiteSpace(),

12
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiResourceRepository.cs

@ -20,7 +20,7 @@ public class MongoApiResourceRepository : MongoDbRepository<IAbpIdentityServerMo
public virtual async Task<ApiResource> FindByNameAsync(string apiResourceName, bool includeDetails = true, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.OrderBy(ar => ar.Id)
.FirstOrDefaultAsync(ar => ar.Name == apiResourceName, GetCancellationToken(cancellationToken));
}
@ -28,7 +28,7 @@ public class MongoApiResourceRepository : MongoDbRepository<IAbpIdentityServerMo
public virtual async Task<List<ApiResource>> FindByNameAsync(string[] apiResourceNames, bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(ar => apiResourceNames.Contains(ar.Name))
.ToListAsync(GetCancellationToken(cancellationToken));
}
@ -36,7 +36,7 @@ public class MongoApiResourceRepository : MongoDbRepository<IAbpIdentityServerMo
public virtual async Task<List<ApiResource>> GetListByScopesAsync(string[] scopeNames, bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(ar => ar.Scopes.Any(x => scopeNames.Contains(x.Scope)))
.ToListAsync(GetCancellationToken(cancellationToken));
}
@ -44,7 +44,7 @@ public class MongoApiResourceRepository : MongoDbRepository<IAbpIdentityServerMo
public virtual async Task<List<ApiResource>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter, bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrWhiteSpace(),
x => x.Name.Contains(filter) ||
x.Description.Contains(filter) ||
@ -56,7 +56,7 @@ public class MongoApiResourceRepository : MongoDbRepository<IAbpIdentityServerMo
public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrWhiteSpace(),
x => x.Name.Contains(filter) ||
x.Description.Contains(filter) ||
@ -66,7 +66,7 @@ public class MongoApiResourceRepository : MongoDbRepository<IAbpIdentityServerMo
public virtual async Task<bool> CheckNameExistAsync(string name, Guid? expectedId = null, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.AnyAsync(ar => ar.Id != expectedId && ar.Name == name, GetCancellationToken(cancellationToken));
}
}

10
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoApiScopeRepository.cs

@ -22,7 +22,7 @@ public class MongoApiScopeRepository : MongoDbRepository<IAbpIdentityServerMongo
public virtual async Task<ApiScope> FindByNameAsync(string scopeName, bool includeDetails = true, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(x => x.Name == scopeName, GetCancellationToken(cancellationToken));
}
@ -30,7 +30,7 @@ public class MongoApiScopeRepository : MongoDbRepository<IAbpIdentityServerMongo
public virtual async Task<List<ApiScope>> GetListByNameAsync(string[] scopeNames, bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(scope => scopeNames.Contains(scope.Name))
.OrderBy(scope => scope.Id)
.ToListAsync(GetCancellationToken(cancellationToken));
@ -39,7 +39,7 @@ public class MongoApiScopeRepository : MongoDbRepository<IAbpIdentityServerMongo
public virtual async Task<List<ApiScope>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null, bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrWhiteSpace(),
x => x.Name.Contains(filter) ||
x.Description.Contains(filter) ||
@ -51,7 +51,7 @@ public class MongoApiScopeRepository : MongoDbRepository<IAbpIdentityServerMongo
public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrWhiteSpace(),
x => x.Name.Contains(filter) ||
x.Description.Contains(filter) ||
@ -61,7 +61,7 @@ public class MongoApiScopeRepository : MongoDbRepository<IAbpIdentityServerMongo
public virtual async Task<bool> CheckNameExistAsync(string name, Guid? expectedId = null, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.AnyAsync(x => x.Id != expectedId && x.Name == name, GetCancellationToken(cancellationToken));
}
}

10
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoClientRepository.cs

@ -26,7 +26,7 @@ public class MongoClientRepository : MongoDbRepository<IAbpIdentityServerMongoDb
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(x => x.ClientId == clientId, GetCancellationToken(cancellationToken));
}
@ -39,7 +39,7 @@ public class MongoClientRepository : MongoDbRepository<IAbpIdentityServerMongoDb
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.ClientId.Contains(filter))
.OrderBy(sorting.IsNullOrWhiteSpace() ? nameof(Client.ClientName) : sorting)
.PageBy(skipCount, maxResultCount)
@ -48,7 +48,7 @@ public class MongoClientRepository : MongoDbRepository<IAbpIdentityServerMongoDb
public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrWhiteSpace(),
x => x.ClientId.Contains(filter))
.LongCountAsync(GetCancellationToken(cancellationToken));
@ -57,7 +57,7 @@ public class MongoClientRepository : MongoDbRepository<IAbpIdentityServerMongoDb
public virtual async Task<List<string>> GetAllDistinctAllowedCorsOriginsAsync(
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.SelectMany(x => x.AllowedCorsOrigins)
.Select(y => y.Origin)
.Distinct()
@ -66,7 +66,7 @@ public class MongoClientRepository : MongoDbRepository<IAbpIdentityServerMongoDb
public virtual async Task<bool> CheckClientIdExistAsync(string clientId, Guid? expectedId = null, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.AnyAsync(c => c.Id != expectedId && c.ClientId == clientId, GetCancellationToken(cancellationToken));
}
}

6
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoDeviceFlowCodesRepository.cs

@ -24,7 +24,7 @@ public class MongoDeviceFlowCodesRepository :
string userCode,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(d => d.UserCode == userCode)
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
@ -32,7 +32,7 @@ public class MongoDeviceFlowCodesRepository :
public virtual async Task<DeviceFlowCodes> FindByDeviceCodeAsync(string deviceCode, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(d => d.DeviceCode == deviceCode)
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
@ -43,7 +43,7 @@ public class MongoDeviceFlowCodesRepository :
int maxResultCount,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(x => x.Expiration != null && x.Expiration < maxExpirationDate)
.OrderBy(x => x.ClientId)
.Take(maxResultCount)

10
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoIdentityResourceRepository.cs

@ -20,7 +20,7 @@ public class MongoIdentityResourceRepository : MongoDbRepository<IAbpIdentitySer
public virtual async Task<List<IdentityResource>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter, bool includeDetails = false, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Name.Contains(filter) ||
x.Description.Contains(filter) ||
x.DisplayName.Contains(filter))
@ -31,7 +31,7 @@ public class MongoIdentityResourceRepository : MongoDbRepository<IAbpIdentitySer
public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrWhiteSpace(),
x => x.Name.Contains(filter) ||
x.Description.Contains(filter) ||
@ -44,7 +44,7 @@ public class MongoIdentityResourceRepository : MongoDbRepository<IAbpIdentitySer
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(x => x.Name == name)
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
@ -53,14 +53,14 @@ public class MongoIdentityResourceRepository : MongoDbRepository<IAbpIdentitySer
public virtual async Task<List<IdentityResource>> GetListByScopeNameAsync(string[] scopeNames, bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(ar => scopeNames.Contains(ar.Name))
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<bool> CheckNameExistAsync(string name, Guid? expectedId = null, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.AnyAsync(ir => ir.Id != expectedId && ir.Name == name, GetCancellationToken(cancellationToken));
}
}

8
modules/identityserver/src/Volo.Abp.IdentityServer.MongoDB/Volo/Abp/IdentityServer/MongoDB/MongoPersistentGrantRepository.cs

@ -27,7 +27,7 @@ public class MongoPersistentGrantRepository : MongoDbRepository<IAbpIdentityServ
public virtual async Task<PersistedGrant> FindByKeyAsync(string key, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(x => x.Key == key)
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
@ -35,7 +35,7 @@ public class MongoPersistentGrantRepository : MongoDbRepository<IAbpIdentityServ
public virtual async Task<List<PersistedGrant>> GetListBySubjectIdAsync(string subjectId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(x => x.SubjectId == subjectId)
.ToListAsync(GetCancellationToken(cancellationToken));
}
@ -43,7 +43,7 @@ public class MongoPersistentGrantRepository : MongoDbRepository<IAbpIdentityServ
public virtual async Task<List<PersistedGrant>> GetListByExpirationAsync(DateTime maxExpirationDate, int maxResultCount,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(x => x.Expiration != null && x.Expiration < maxExpirationDate)
.OrderBy(x => x.ClientId)
.Take(maxResultCount)
@ -94,7 +94,7 @@ public class MongoPersistentGrantRepository : MongoDbRepository<IAbpIdentityServ
string type,
CancellationToken cancellationToken = default)
{
return (await GetMongoQueryableAsync(cancellationToken))
return (await GetQueryableAsync(cancellationToken))
.WhereIf(!subjectId.IsNullOrWhiteSpace(), x => x.SubjectId == subjectId)
.WhereIf(!sessionId.IsNullOrWhiteSpace(), x => x.SessionId == sessionId)
.WhereIf(!clientId.IsNullOrWhiteSpace(), x => x.ClientId == clientId)

14
modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Applications/MongoOpenIddictApplicationRepository.cs

@ -21,7 +21,7 @@ public class MongoOpenIddictApplicationRepository : MongoDbRepository<OpenIddict
public virtual async Task<List<OpenIddictApplication>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null,
CancellationToken cancellationToken = default)
{
return await ((await GetMongoQueryableAsync(cancellationToken)))
return await ((await GetQueryableAsync(cancellationToken)))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.ClientId.Contains(filter))
.OrderBy(sorting.IsNullOrWhiteSpace() ? nameof(OpenIddictApplication.CreationTime) + " desc" : sorting)
.PageBy(skipCount, maxResultCount)
@ -30,35 +30,35 @@ public class MongoOpenIddictApplicationRepository : MongoDbRepository<OpenIddict
public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await ((await GetMongoQueryableAsync(cancellationToken)))
return await ((await GetQueryableAsync(cancellationToken)))
.WhereIf(!filter.IsNullOrWhiteSpace(), x => x.ClientId.Contains(filter))
.LongCountAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<OpenIddictApplication> FindByClientIdAsync(string clientId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.FirstOrDefaultAsync(x => x.ClientId == clientId, cancellationToken);
}
public virtual async Task<List<OpenIddictApplication>> FindByPostLogoutRedirectUriAsync(string address, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.PostLogoutRedirectUris.Contains(address)).ToListAsync(GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync(cancellationToken)).Where(x => x.PostLogoutRedirectUris.Contains(address)).ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<OpenIddictApplication>> FindByRedirectUriAsync(string address, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.RedirectUris.Contains(address)).ToListAsync(GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync(cancellationToken)).Where(x => x.RedirectUris.Contains(address)).ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<TResult> GetAsync<TState, TResult>(Func<IQueryable<OpenIddictApplication>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken = default)
{
return await query(await GetMongoQueryableAsync(cancellationToken), state).FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
return await query(await GetQueryableAsync(cancellationToken), state).FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<OpenIddictApplication>> ListAsync(int? count, int? offset, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.OrderBy(x => x.Id)
.SkipIf<OpenIddictApplication, IQueryable<OpenIddictApplication>>(offset.HasValue, offset)
.TakeIf<OpenIddictApplication, IQueryable<OpenIddictApplication>>(count.HasValue, count)

16
modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Authorizations/MongoOpenIddictAuthorizationRepository.cs

@ -29,7 +29,7 @@ public class MongoOpenIddictAuthorizationRepository : MongoDbRepository<OpenIddi
public virtual async Task<List<OpenIddictAuthorization>> FindAsync(string subject, Guid? client, string status, string type, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(!subject.IsNullOrWhiteSpace(), x => x.Subject == subject)
.WhereIf(client.HasValue, x => x.ApplicationId == client)
.WhereIf(!status.IsNullOrWhiteSpace(), x => x.Status == status)
@ -39,22 +39,22 @@ public class MongoOpenIddictAuthorizationRepository : MongoDbRepository<OpenIddi
public virtual async Task<List<OpenIddictAuthorization>> FindByApplicationIdAsync(Guid applicationId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))).Where(x => x.ApplicationId == applicationId).ToListAsync(GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync(GetCancellationToken(cancellationToken))).Where(x => x.ApplicationId == applicationId).ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<OpenIddictAuthorization> FindByIdAsync(Guid id, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))).FirstOrDefaultAsync(x => x.Id == id, GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync(GetCancellationToken(cancellationToken))).FirstOrDefaultAsync(x => x.Id == id, GetCancellationToken(cancellationToken));
}
public virtual async Task<List<OpenIddictAuthorization>> FindBySubjectAsync(string subject, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))).Where(x => x.Subject == subject).ToListAsync(GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync(GetCancellationToken(cancellationToken))).Where(x => x.Subject == subject).ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<OpenIddictAuthorization>> ListAsync(int? count, int? offset, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
return await (await GetQueryableAsync(GetCancellationToken(cancellationToken)))
.OrderBy(authorization => authorization.Id!)
.SkipIf<OpenIddictAuthorization, IQueryable<OpenIddictAuthorization>>(offset.HasValue, offset)
.TakeIf<OpenIddictAuthorization, IQueryable<OpenIddictAuthorization>>(count.HasValue, count)
@ -63,18 +63,18 @@ public class MongoOpenIddictAuthorizationRepository : MongoDbRepository<OpenIddi
public virtual async Task<long> PruneAsync(DateTime date, CancellationToken cancellationToken = default)
{
var tokenIds = await (await GetMongoQueryableAsync<OpenIddictToken>(cancellationToken))
var tokenIds = await (await GetQueryableAsync<OpenIddictToken>(cancellationToken))
.Where(x => x.AuthorizationId != null)
.Select(x => x.AuthorizationId.Value)
.ToListAsync(GetCancellationToken(cancellationToken));
var authorizations = await (await GetMongoQueryableAsync(cancellationToken))
var authorizations = await (await GetQueryableAsync(cancellationToken))
.Where(x => x.CreationDate < date)
.Where(x => x.Status != OpenIddictConstants.Statuses.Valid || (x.Type == OpenIddictConstants.AuthorizationTypes.AdHoc && !tokenIds.Contains(x.Id)))
.Select(x => x.Id)
.ToListAsync(cancellationToken: cancellationToken);
var tokens = await (await GetMongoQueryableAsync<OpenIddictToken>(cancellationToken))
var tokens = await (await GetQueryableAsync<OpenIddictToken>(cancellationToken))
.Where(x => x.AuthorizationId != null && authorizations.Contains(x.AuthorizationId.Value))
.ToListAsync(cancellationToken: cancellationToken);

14
modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Scopes/MongoOpenIddictScopeRepository.cs

@ -21,7 +21,7 @@ public class MongoOpenIddictScopeRepository : MongoDbRepository<OpenIddictMongoD
public virtual async Task<List<OpenIddictScope>> GetListAsync(string sorting, int skipCount, int maxResultCount, string filter = null,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrWhiteSpace(), x =>
x.Name.Contains(filter) ||
x.DisplayName.Contains(filter) ||
@ -33,7 +33,7 @@ public class MongoOpenIddictScopeRepository : MongoDbRepository<OpenIddictMongoD
public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrWhiteSpace(), x =>
x.Name.Contains(filter) ||
x.DisplayName.Contains(filter) ||
@ -43,31 +43,31 @@ public class MongoOpenIddictScopeRepository : MongoDbRepository<OpenIddictMongoD
public virtual async Task<OpenIddictScope> FindByIdAsync(Guid id, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).FirstOrDefaultAsync(x => x.Id == id, GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync(cancellationToken)).FirstOrDefaultAsync(x => x.Id == id, GetCancellationToken(cancellationToken));
}
public virtual async Task<OpenIddictScope> FindByNameAsync(string name, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).FirstOrDefaultAsync(x => x.Name == name, GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync(cancellationToken)).FirstOrDefaultAsync(x => x.Name == name, GetCancellationToken(cancellationToken));
}
public virtual async Task<List<OpenIddictScope>> FindByNamesAsync(string[] names, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
return await (await GetQueryableAsync(GetCancellationToken(cancellationToken)))
.Where(x => names.Contains(x.Name))
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<OpenIddictScope>> FindByResourceAsync(string resource, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
return await (await GetQueryableAsync(GetCancellationToken(cancellationToken)))
.Where(x => x.Resources.Contains(resource))
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<OpenIddictScope>> ListAsync(int? count, int? offset, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
return await (await GetQueryableAsync(GetCancellationToken(cancellationToken)))
.OrderBy(x => x.Id)
.SkipIf<OpenIddictScope, IQueryable<OpenIddictScope>>(offset.HasValue, offset)
.TakeIf<OpenIddictScope, IQueryable<OpenIddictScope>>(count.HasValue, count)

24
modules/openiddict/src/Volo.Abp.OpenIddict.MongoDB/Volo/Abp/OpenIddict/Tokens/MongoOpenIddictTokenRepository.cs

@ -21,7 +21,7 @@ public class MongoOpenIddictTokenRepository : MongoDbRepository<OpenIddictMongoD
public virtual async Task DeleteManyByApplicationIdAsync(Guid applicationId, bool autoSave = false, CancellationToken cancellationToken = default)
{
var tokens = await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
var tokens = await (await GetQueryableAsync(GetCancellationToken(cancellationToken)))
.Where(x => x.ApplicationId == applicationId)
.ToListAsync(GetCancellationToken(cancellationToken));
@ -31,7 +31,7 @@ public class MongoOpenIddictTokenRepository : MongoDbRepository<OpenIddictMongoD
public virtual async Task DeleteManyByAuthorizationIdAsync(Guid authorizationId, bool autoSave = false,
CancellationToken cancellationToken = default)
{
var tokens = await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
var tokens = await (await GetQueryableAsync(GetCancellationToken(cancellationToken)))
.Where(x => x.AuthorizationId == authorizationId)
.ToListAsync(GetCancellationToken(cancellationToken));
@ -40,7 +40,7 @@ public class MongoOpenIddictTokenRepository : MongoDbRepository<OpenIddictMongoD
public virtual async Task DeleteManyByAuthorizationIdsAsync(Guid[] authorizationIds, bool autoSave = false, CancellationToken cancellationToken = default)
{
var tokens = await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
var tokens = await (await GetQueryableAsync(GetCancellationToken(cancellationToken)))
.Where(x => x.AuthorizationId != null && authorizationIds.Contains(x.AuthorizationId.Value))
.ToListAsync(GetCancellationToken(cancellationToken));
@ -49,7 +49,7 @@ public class MongoOpenIddictTokenRepository : MongoDbRepository<OpenIddictMongoD
public virtual async Task<List<OpenIddictToken>> FindAsync(string subject, Guid? client, string status, string type, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(!subject.IsNullOrWhiteSpace(), x => x.Subject == subject)
.WhereIf(client.HasValue, x => x.ApplicationId == client)
.WhereIf(!status.IsNullOrWhiteSpace(), x => x.Status == status)
@ -59,38 +59,38 @@ public class MongoOpenIddictTokenRepository : MongoDbRepository<OpenIddictMongoD
public virtual async Task<List<OpenIddictToken>> FindByApplicationIdAsync(Guid applicationId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
return await (await GetQueryableAsync(GetCancellationToken(cancellationToken)))
.Where(x => x.ApplicationId == applicationId)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<OpenIddictToken>> FindByAuthorizationIdAsync(Guid authorizationId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
return await (await GetQueryableAsync(GetCancellationToken(cancellationToken)))
.Where(x => x.AuthorizationId == authorizationId)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<OpenIddictToken> FindByIdAsync(Guid id, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))).FirstOrDefaultAsync(x => x.Id == id, GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync(GetCancellationToken(cancellationToken))).FirstOrDefaultAsync(x => x.Id == id, GetCancellationToken(cancellationToken));
}
public virtual async Task<OpenIddictToken> FindByReferenceIdAsync(string referenceId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken))).FirstOrDefaultAsync(x => x.ReferenceId == referenceId, GetCancellationToken(cancellationToken));
return await (await GetQueryableAsync(GetCancellationToken(cancellationToken))).FirstOrDefaultAsync(x => x.ReferenceId == referenceId, GetCancellationToken(cancellationToken));
}
public virtual async Task<List<OpenIddictToken>> FindBySubjectAsync(string subject, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
return await (await GetQueryableAsync(GetCancellationToken(cancellationToken)))
.Where(x => x.Subject == subject)
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task<List<OpenIddictToken>> ListAsync(int? count, int? offset, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
return await (await GetQueryableAsync(GetCancellationToken(cancellationToken)))
.OrderBy(x => x.Id)
.SkipIf<OpenIddictToken, IQueryable<OpenIddictToken>>(offset.HasValue, offset)
.TakeIf<OpenIddictToken, IQueryable<OpenIddictToken>>(count.HasValue, count)
@ -99,12 +99,12 @@ public class MongoOpenIddictTokenRepository : MongoDbRepository<OpenIddictMongoD
public virtual async Task<long> PruneAsync(DateTime date, CancellationToken cancellationToken = default)
{
var authorizationIds = await (await GetMongoQueryableAsync<OpenIddictAuthorization>(cancellationToken))
var authorizationIds = await (await GetQueryableAsync<OpenIddictAuthorization>(cancellationToken))
.Where(x => x.Status != OpenIddictConstants.Statuses.Valid)
.Select(x => x.Id)
.ToListAsync(GetCancellationToken(cancellationToken));
var tokens = await (await GetMongoQueryableAsync(GetCancellationToken(cancellationToken)))
var tokens = await (await GetQueryableAsync(GetCancellationToken(cancellationToken)))
.Where(x => x.CreationDate < date)
.Where(x => (x.Status != OpenIddictConstants.Statuses.Inactive &&
x.Status != OpenIddictConstants.Statuses.Valid) ||

2
modules/permission-management/src/Volo.Abp.PermissionManagement.MongoDB/Volo/Abp/PermissionManagement/MongoDb/MongoPermissionDefinitionRecordRepository.cs

@ -23,7 +23,7 @@ public class MongoPermissionDefinitionRecordRepository :
CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(
s => s.Name == name,

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

@ -27,7 +27,7 @@ public class MongoPermissionGrantRepository :
CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(s =>
s.Name == name &&
@ -43,7 +43,7 @@ public class MongoPermissionGrantRepository :
CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(s =>
s.ProviderName == providerName &&
s.ProviderKey == providerKey
@ -54,7 +54,7 @@ public class MongoPermissionGrantRepository :
CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(s =>
names.Contains(s.Name) &&
s.ProviderName == providerName &&

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

@ -17,7 +17,7 @@ public class MongoSettingDefinitionRecordRepository : MongoDbRepository<ISetting
public virtual async Task<SettingDefinitionRecord> FindByNameAsync(string name, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(s => s.Name == name, GetCancellationToken(cancellationToken));
}

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

@ -24,7 +24,7 @@ public class MongoSettingRepository : MongoDbRepository<ISettingManagementMongoD
string providerKey,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(
s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey,
@ -36,7 +36,7 @@ public class MongoSettingRepository : MongoDbRepository<ISettingManagementMongoD
string providerKey,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(s => s.ProviderName == providerName && s.ProviderKey == providerKey)
.ToListAsync(GetCancellationToken(cancellationToken));
}
@ -47,7 +47,7 @@ public class MongoSettingRepository : MongoDbRepository<ISettingManagementMongoD
string providerKey,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(s => names.Contains(s.Name) && s.ProviderName == providerName && s.ProviderKey == providerKey)
.ToListAsync(GetCancellationToken(cancellationToken));
}

10
modules/tenant-management/src/Volo.Abp.TenantManagement.MongoDB/Volo/Abp/TenantManagement/MongoDb/MongoTenantRepository.cs

@ -24,21 +24,21 @@ public class MongoTenantRepository : MongoDbRepository<ITenantManagementMongoDbC
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.FirstOrDefaultAsync(t => t.NormalizedName == normalizedName, GetCancellationToken(cancellationToken));
}
[Obsolete("Use FindByNameAsync method.")]
public virtual Tenant FindByName(string normalizedName, bool includeDetails = true)
{
return GetMongoQueryable()
return GetQueryable()
.FirstOrDefault(t => t.NormalizedName == normalizedName);
}
[Obsolete("Use FindAsync method.")]
public virtual Tenant FindById(Guid id, bool includeDetails = true)
{
return GetMongoQueryable()
return GetQueryable()
.FirstOrDefault(t => t.Id == id);
}
@ -50,7 +50,7 @@ public class MongoTenantRepository : MongoDbRepository<ITenantManagementMongoDbC
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(
!filter.IsNullOrWhiteSpace(),
u =>
@ -63,7 +63,7 @@ public class MongoTenantRepository : MongoDbRepository<ITenantManagementMongoDbC
public virtual async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(
!filter.IsNullOrWhiteSpace(),
u =>

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

@ -24,7 +24,7 @@ public abstract class MongoUserRepositoryBase<TDbContext, TUser> : MongoDbReposi
public virtual async Task<TUser> FindByUserNameAsync(string userName, CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(u => u.UserName == userName, cancellationToken);
}
@ -32,7 +32,7 @@ public abstract class MongoUserRepositoryBase<TDbContext, TUser> : MongoDbReposi
public virtual async Task<List<TUser>> GetListAsync(IEnumerable<Guid> ids, CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.Where(u => ids.Contains(u.Id))
.ToListAsync(cancellationToken);
}
@ -45,7 +45,7 @@ public abstract class MongoUserRepositoryBase<TDbContext, TUser> : MongoDbReposi
CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(
!filter.IsNullOrWhiteSpace(),
u =>
@ -62,7 +62,7 @@ public abstract class MongoUserRepositoryBase<TDbContext, TUser> : MongoDbReposi
public async Task<long> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellationToken))
return await (await GetQueryableAsync(cancellationToken))
.WhereIf(
!filter.IsNullOrWhiteSpace(),
u =>

2
templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/Samples/SampleRepositoryTests.cs

@ -32,7 +32,7 @@ public class SampleRepositoryTests : MyProjectNameMongoDbTestBase
await WithUnitOfWorkAsync(async () =>
{
//Act
var adminUser = await (await _appUserRepository.GetMongoQueryableAsync())
var adminUser = await (await _appUserRepository.GetQueryableAsync())
.FirstOrDefaultAsync(u => u.UserName == "admin");
//Assert

Loading…
Cancel
Save