diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs index 9dec7877f8..40496aaef8 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs @@ -28,8 +28,8 @@ namespace Volo.CmsKit.Comments Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - var query = from comment in DbSet - join user in DbContext.Set() on comment.CreatorId equals user.Id + var query = from comment in (await GetDbSetAsync()) + join user in (await GetDbContextAsync()).Set() on comment.CreatorId equals user.Id where entityType == comment.EntityType && entityId == comment.EntityId orderby comment.CreationTime select new CommentWithAuthorQueryResultItem @@ -45,7 +45,7 @@ namespace Volo.CmsKit.Comments Comment comment, CancellationToken cancellationToken = default) { - var replies = await DbSet + var replies = await (await GetDbSetAsync()) .Where(x => x.RepliedCommentId == comment.Id) .ToListAsync(GetCancellationToken(cancellationToken)); diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Pages/EfCorePageRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Pages/EfCorePageRepository.cs index 4502a13b4c..93a7df00d2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Pages/EfCorePageRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Pages/EfCorePageRepository.cs @@ -23,9 +23,9 @@ namespace Volo.CmsKit.Pages return FindAsync(x => x.Url == url); } - public Task DoesExistAsync(string url) + public async Task DoesExistAsync(string url) { - return DbSet.AnyAsync(x => x.Url == url); + return await (await GetDbSetAsync()).AnyAsync(x => x.Url == url); } } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Ratings/EfCoreRatingRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Ratings/EfCoreRatingRepository.cs index 810335b4d6..a48c288932 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Ratings/EfCoreRatingRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Ratings/EfCoreRatingRepository.cs @@ -24,7 +24,7 @@ namespace Volo.CmsKit.Ratings Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - var rating = await DbSet.FirstOrDefaultAsync( + var rating = await (await GetDbSetAsync()).FirstOrDefaultAsync( r => r.EntityType == entityType && r.EntityId == entityId && r.CreatorId == userId, GetCancellationToken(cancellationToken)); @@ -38,7 +38,7 @@ namespace Volo.CmsKit.Ratings Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); var query = ( - from rating in DbSet + from rating in (await GetDbSetAsync()) where rating.EntityType == entityType && rating.EntityId == entityId group rating by rating.StarCount into g @@ -54,4 +54,4 @@ namespace Volo.CmsKit.Ratings return ratings; } } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Reactions/EfCoreUserReactionRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Reactions/EfCoreUserReactionRepository.cs index da89de4c74..65824c79b6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Reactions/EfCoreUserReactionRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Reactions/EfCoreUserReactionRepository.cs @@ -30,7 +30,7 @@ namespace Volo.CmsKit.Reactions Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); Check.NotNullOrWhiteSpace(reactionName, nameof(reactionName)); - return await DbSet + return await (await GetDbSetAsync()) .Where(x => x.CreatorId == userId && x.EntityType == entityType && @@ -48,7 +48,7 @@ namespace Volo.CmsKit.Reactions Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - return await DbSet + return await (await GetDbSetAsync()) .Where(x => x.CreatorId == userId && x.EntityType == entityType && @@ -64,7 +64,7 @@ namespace Volo.CmsKit.Reactions Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - return await DbSet + return await (await GetDbSetAsync()) .Where(x => x.EntityType == entityType && x.EntityId == entityId) diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs index 0b6cfe1f48..3d917a059a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs @@ -19,13 +19,13 @@ namespace Volo.CmsKit.Tags { } - public virtual Task AnyAsync( + public virtual async Task AnyAsync( [NotNull] string entityType, [NotNull] string name, Guid? tenantId = null, CancellationToken cancellationToken = default) { - return DbSet.AnyAsync(x => + return await (await GetDbSetAsync()).AnyAsync(x => x.EntityType == entityType && x.Name == name && x.TenantId == tenantId, @@ -64,12 +64,12 @@ namespace Volo.CmsKit.Tags Guid? tenantId = null, CancellationToken cancellationToken = default) { - var entityTagIds = await DbContext.Set() + var entityTagIds = await (await GetDbContextAsync()).Set() .Where(q => q.EntityId == entityId && q.TenantId == tenantId) .Select(q => q.TagId) .ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); - var query = DbSet + var query = (await GetDbSetAsync()) .Where(x => x.EntityType == entityType && x.TenantId == tenantId && entityTagIds.Contains(x.Id)); diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs index 9564bcf9f8..5d16c6d55c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs @@ -26,15 +26,15 @@ namespace Volo.CmsKit.MongoDB.Comments Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - var authorsQuery = from comment in GetMongoQueryable() - join user in DbContext.CmsUsers on comment.CreatorId equals user.Id + var authorsQuery = from comment in (await GetMongoQueryableAsync(cancellationToken)) + join user in (await GetDbContextAsync(cancellationToken)).CmsUsers on comment.CreatorId equals user.Id where entityType == comment.EntityType && entityId == comment.EntityId orderby comment.CreationTime select user; var authors = await authorsQuery.ToListAsync(GetCancellationToken(cancellationToken)); - var comments = await GetMongoQueryable() + var comments = await (await GetMongoQueryableAsync(cancellationToken)) .Where(c => c.EntityId == entityId && c.EntityType == entityType) .OrderBy(c => c.CreationTime) .ToListAsync(GetCancellationToken(cancellationToken)); @@ -53,7 +53,7 @@ namespace Volo.CmsKit.MongoDB.Comments Comment comment, CancellationToken cancellationToken = default) { - var replies = await GetMongoQueryable() + var replies = await (await GetMongoQueryableAsync(cancellationToken)) .Where(x => x.RepliedCommentId == comment.Id) .ToListAsync(GetCancellationToken(cancellationToken)); diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Pages/MongoPageRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Pages/MongoPageRepository.cs index e7c6cd32f5..8537500c96 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Pages/MongoPageRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Pages/MongoPageRepository.cs @@ -22,10 +22,10 @@ namespace Volo.CmsKit.MongoDB.Pages { return FindAsync(x => x.Url == url); } - - public Task DoesExistAsync(string url) + + public async Task DoesExistAsync(string url) { - return GetMongoQueryable().AnyAsync(x => x.Url == url); + return await (await GetMongoQueryableAsync()).AnyAsync(x => x.Url == url); } } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Ratings/MongoRatingRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Ratings/MongoRatingRepository.cs index 92f7f992da..8ff8b4f81d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Ratings/MongoRatingRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Ratings/MongoRatingRepository.cs @@ -25,7 +25,7 @@ namespace Volo.CmsKit.MongoDB.Ratings Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - var rating = await GetMongoQueryable() + var rating = await (await GetMongoQueryableAsync(cancellationToken)) .FirstOrDefaultAsync(r => r.EntityType == entityType && r.EntityId == entityId && r.CreatorId == userId, GetCancellationToken(cancellationToken)); @@ -39,7 +39,7 @@ namespace Volo.CmsKit.MongoDB.Ratings Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); var query = ( - from rating in GetMongoQueryable() + from rating in (await GetMongoQueryableAsync(cancellationToken)) where rating.EntityType == entityType && rating.EntityId == entityId group rating by rating.StarCount into g @@ -55,4 +55,4 @@ namespace Volo.CmsKit.MongoDB.Ratings return ratings; } } -} \ No newline at end of file +} diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Reactions/MongoUserReactionRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Reactions/MongoUserReactionRepository.cs index e3a09c4514..6ac4cf1b80 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Reactions/MongoUserReactionRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Reactions/MongoUserReactionRepository.cs @@ -29,7 +29,7 @@ namespace Volo.CmsKit.MongoDB.Reactions Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); Check.NotNullOrWhiteSpace(reactionName, nameof(reactionName)); - return await GetMongoQueryable() + return await (await GetMongoQueryableAsync(cancellationToken)) .Where(x => x.CreatorId == userId && x.EntityType == entityType && @@ -47,7 +47,7 @@ namespace Volo.CmsKit.MongoDB.Reactions Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - return await GetMongoQueryable() + return await (await GetMongoQueryableAsync(cancellationToken)) .Where(x => x.CreatorId == userId && x.EntityType == entityType && @@ -63,7 +63,7 @@ namespace Volo.CmsKit.MongoDB.Reactions Check.NotNullOrWhiteSpace(entityType, nameof(entityType)); Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); - return await GetMongoQueryable() + return await (await GetMongoQueryableAsync(cancellationToken)) .Where(x => x.EntityType == entityType && x.EntityId == entityId) diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs index 86dc20d83c..02c42c22fb 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs @@ -18,13 +18,13 @@ namespace Volo.CmsKit.MongoDB.Tags { } - public Task AnyAsync( + public async Task AnyAsync( [NotNull] string entityType, [NotNull] string name, Guid? tenantId = null, CancellationToken cancellationToken = default) { - return GetMongoQueryable() + return await (await GetMongoQueryableAsync(cancellationToken)) .AnyAsync(x => x.EntityType == entityType && x.Name == name && @@ -64,13 +64,13 @@ namespace Volo.CmsKit.MongoDB.Tags Guid? tenantId = null, CancellationToken cancellationToken = default) { - var entityTagIds = await DbContext.EntityTags.AsQueryable() + var entityTagIds = await (await GetDbContextAsync(cancellationToken)).EntityTags.AsQueryable() .Where(q => q.EntityId == entityId && q.TenantId == tenantId) .Select(q => q.TagId) .ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); - var query = GetMongoQueryable() - .Where(x => + var query = (await GetMongoQueryableAsync(cancellationToken)) + .Where(x => x.EntityType == entityType && x.TenantId == tenantId && entityTagIds.Contains(x.Id));