diff --git a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Blogs/EfCoreBlogRepository.cs b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Blogs/EfCoreBlogRepository.cs index 604f7ca8b5..564d45dc7a 100644 --- a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Blogs/EfCoreBlogRepository.cs +++ b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Blogs/EfCoreBlogRepository.cs @@ -17,7 +17,7 @@ namespace Volo.Blogging.Blogs public async Task FindByShortNameAsync(string shortName) { - return await DbSet.FirstOrDefaultAsync(p => p.ShortName == shortName); + return await (await GetDbSetAsync()).FirstOrDefaultAsync(p => p.ShortName == shortName); } } } diff --git a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Comments/EfCoreCommentRepository.cs b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Comments/EfCoreCommentRepository.cs index 751d106071..6c28b521aa 100644 --- a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Comments/EfCoreCommentRepository.cs +++ b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Comments/EfCoreCommentRepository.cs @@ -11,14 +11,14 @@ namespace Volo.Blogging.Comments { public class EfCoreCommentRepository : EfCoreRepository, ICommentRepository { - public EfCoreCommentRepository(IDbContextProvider dbContextProvider) + public EfCoreCommentRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) { } public async Task> GetListOfPostAsync(Guid postId) { - return await DbSet + return await (await GetDbSetAsync()) .Where(a => a.PostId == postId) .OrderBy(a => a.CreationTime) .ToListAsync(); @@ -26,20 +26,20 @@ namespace Volo.Blogging.Comments public async Task GetCommentCountOfPostAsync(Guid postId) { - return await DbSet + return await (await GetDbSetAsync()) .CountAsync(a => a.PostId == postId); } public async Task> GetRepliesOfComment(Guid id) { - return await DbSet + return await (await GetDbSetAsync()) .Where(a => a.RepliedCommentId == id).ToListAsync(); } public async Task DeleteOfPost(Guid id) { - var recordsToDelete = DbSet.Where(pt => pt.PostId == id); - DbSet.RemoveRange(recordsToDelete); + var recordsToDelete = (await GetDbSetAsync()).Where(pt => pt.PostId == id); + (await GetDbSetAsync()).RemoveRange(recordsToDelete); } } } diff --git a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Posts/EfCorePostRepository.cs b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Posts/EfCorePostRepository.cs index b152f3ae7d..a5a84fd340 100644 --- a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Posts/EfCorePostRepository.cs +++ b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Posts/EfCorePostRepository.cs @@ -20,24 +20,24 @@ namespace Volo.Blogging.Posts public async Task> GetPostsByBlogId(Guid id) { - return await DbSet.Where(p => p.BlogId == id).OrderByDescending(p=>p.CreationTime).ToListAsync(); + return await (await GetDbSetAsync()).Where(p => p.BlogId == id).OrderByDescending(p=>p.CreationTime).ToListAsync(); } - public Task IsPostUrlInUseAsync(Guid blogId, string url, Guid? excludingPostId = null) + public async Task IsPostUrlInUseAsync(Guid blogId, string url, Guid? excludingPostId = null) { - var query = DbSet.Where(p => blogId == p.BlogId && p.Url == url); + var query = (await GetDbSetAsync()).Where(p => blogId == p.BlogId && p.Url == url); if (excludingPostId != null) { query = query.Where(p => excludingPostId != p.Id); } - return query.AnyAsync(); + return await query.AnyAsync(); } public async Task GetPostByUrl(Guid blogId, string url) { - var post = await DbSet.FirstOrDefaultAsync(p => p.BlogId == blogId && p.Url == url); + var post = await (await GetDbSetAsync()).FirstOrDefaultAsync(p => p.BlogId == blogId && p.Url == url); if (post == null) { @@ -51,18 +51,18 @@ namespace Volo.Blogging.Posts { if (!descending) { - return await DbSet.Where(x=>x.BlogId==blogId).OrderByDescending(x => x.CreationTime).ToListAsync(); + return await (await GetDbSetAsync()).Where(x=>x.BlogId==blogId).OrderByDescending(x => x.CreationTime).ToListAsync(); } else { - return await DbSet.Where(x => x.BlogId == blogId).OrderBy(x => x.CreationTime).ToListAsync(); + return await (await GetDbSetAsync()).Where(x => x.BlogId == blogId).OrderBy(x => x.CreationTime).ToListAsync(); } } - public override IQueryable WithDetails() + public override async Task> WithDetailsAsync() { - return GetQueryable().IncludeDetails(); + return (await GetQueryableAsync()).IncludeDetails(); } } } diff --git a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Tagging/EfCoreTagRepository.cs b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Tagging/EfCoreTagRepository.cs index 3e897fa7e3..a92ae780da 100644 --- a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Tagging/EfCoreTagRepository.cs +++ b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Tagging/EfCoreTagRepository.cs @@ -19,27 +19,27 @@ namespace Volo.Blogging.Tagging public async Task> GetListAsync(Guid blogId) { - return await DbSet.Where(t=>t.BlogId == blogId).ToListAsync(); + return await (await GetDbSetAsync()).Where(t=>t.BlogId == blogId).ToListAsync(); } public async Task GetByNameAsync(Guid blogId, string name) { - return await DbSet.FirstAsync(t=> t.BlogId == blogId && t.Name == name); + return await (await GetDbSetAsync()).FirstAsync(t=> t.BlogId == blogId && t.Name == name); } public async Task FindByNameAsync(Guid blogId, string name) { - return await DbSet.FirstOrDefaultAsync(t => t.BlogId == blogId && t.Name == name); + return await (await GetDbSetAsync()).FirstOrDefaultAsync(t => t.BlogId == blogId && t.Name == name); } public async Task> GetListAsync(IEnumerable ids) { - return await DbSet.Where(t => ids.Contains(t.Id)).ToListAsync(); + return await (await GetDbSetAsync()).Where(t => ids.Contains(t.Id)).ToListAsync(); } public async Task DecreaseUsageCountOfTagsAsync(List ids, CancellationToken cancellationToken = default) { - var tags = await DbSet + var tags = await (await GetDbSetAsync()) .Where(t => ids.Any(id => id == t.Id)) .ToListAsync(GetCancellationToken(cancellationToken)); diff --git a/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Blogs/MongoBlogRepository.cs b/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Blogs/MongoBlogRepository.cs index b1c7b5d319..6025dfe3ca 100644 --- a/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Blogs/MongoBlogRepository.cs +++ b/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Blogs/MongoBlogRepository.cs @@ -15,7 +15,7 @@ namespace Volo.Blogging.Blogs public async Task FindByShortNameAsync(string shortName) { - return await GetMongoQueryable().FirstOrDefaultAsync(p => p.ShortName == shortName); + return await (await GetMongoQueryableAsync()).FirstOrDefaultAsync(p => p.ShortName == shortName); } } } diff --git a/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Comments/MongoCommentRepository.cs b/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Comments/MongoCommentRepository.cs index b17c7f906f..bbbe60345b 100644 --- a/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Comments/MongoCommentRepository.cs +++ b/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Comments/MongoCommentRepository.cs @@ -17,7 +17,7 @@ namespace Volo.Blogging.Comments public async Task> GetListOfPostAsync(Guid postId) { - return await GetMongoQueryable() + return await (await GetMongoQueryableAsync()) .Where(a => a.PostId == postId) .OrderBy(a => a.CreationTime) .ToListAsync(); @@ -25,19 +25,19 @@ namespace Volo.Blogging.Comments public async Task GetCommentCountOfPostAsync(Guid postId) { - return await GetMongoQueryable() + return await (await GetMongoQueryableAsync()) .CountAsync(a => a.PostId == postId); } public async Task> GetRepliesOfComment(Guid id) { - return await GetMongoQueryable() + return await (await GetMongoQueryableAsync()) .Where(a => a.RepliedCommentId == id).ToListAsync(); } public async Task DeleteOfPost(Guid id) { - var recordsToDelete = GetMongoQueryable().Where(pt => pt.PostId == id); + var recordsToDelete = (await GetMongoQueryableAsync()).Where(pt => pt.PostId == id); foreach (var record in recordsToDelete) { diff --git a/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Posts/MongoPostRepository.cs b/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Posts/MongoPostRepository.cs index e12e5f29de..27f4ad4348 100644 --- a/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Posts/MongoPostRepository.cs +++ b/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Posts/MongoPostRepository.cs @@ -18,25 +18,25 @@ namespace Volo.Blogging.Posts public async Task> GetPostsByBlogId(Guid id) { - return await GetMongoQueryable().Where(p => p.BlogId == id).OrderByDescending(p => p.CreationTime).ToListAsync(); + return await (await GetMongoQueryableAsync()).Where(p => p.BlogId == id).OrderByDescending(p => p.CreationTime).ToListAsync(); } - public Task IsPostUrlInUseAsync(Guid blogId, string url, Guid? excludingPostId = null) + public async Task IsPostUrlInUseAsync(Guid blogId, string url, Guid? excludingPostId = null) { - var query = GetMongoQueryable().Where(p => blogId == p.BlogId && p.Url == url); + var query = (await GetMongoQueryableAsync()).Where(p => blogId == p.BlogId && p.Url == url); if (excludingPostId != null) { query = query.Where(p => excludingPostId != p.Id); } - return query.AnyAsync(); + return await query.AnyAsync(); } public async Task GetPostByUrl(Guid blogId, string url) { - var post = await GetMongoQueryable().FirstOrDefaultAsync(p => p.BlogId == blogId && p.Url == url); + var post = await (await GetMongoQueryableAsync()).FirstOrDefaultAsync(p => p.BlogId == blogId && p.Url == url); if (post == null) { @@ -48,7 +48,7 @@ namespace Volo.Blogging.Posts public async Task> GetOrderedList(Guid blogId, bool @descending = false) { - var query = GetMongoQueryable().Where(x => x.BlogId == blogId); + var query = (await GetMongoQueryableAsync()).Where(x => x.BlogId == blogId); if (!descending) { diff --git a/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Tagging/MongoTagRepository.cs b/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Tagging/MongoTagRepository.cs index 2c0b3b97bf..f0024b37d7 100644 --- a/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Tagging/MongoTagRepository.cs +++ b/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Tagging/MongoTagRepository.cs @@ -20,27 +20,27 @@ namespace Volo.Blogging.Tagging public async Task> GetListAsync(Guid blogId) { - return await GetMongoQueryable().Where(t => t.BlogId == blogId).ToListAsync(); + return await (await GetMongoQueryableAsync()).Where(t => t.BlogId == blogId).ToListAsync(); } public async Task GetByNameAsync(Guid blogId, string name) { - return await GetMongoQueryable().Where(t => t.BlogId == blogId && t.Name == name).FirstAsync(); + return await (await GetMongoQueryableAsync()).Where(t => t.BlogId == blogId && t.Name == name).FirstAsync(); } public async Task FindByNameAsync(Guid blogId, string name) { - return await GetMongoQueryable().Where(t => t.BlogId == blogId && t.Name == name).FirstOrDefaultAsync(); + return await (await GetMongoQueryableAsync()).Where(t => t.BlogId == blogId && t.Name == name).FirstOrDefaultAsync(); } public async Task> GetListAsync(IEnumerable ids) { - return await GetMongoQueryable().Where(t => ids.Contains(t.Id)).ToListAsync(); + return await (await GetMongoQueryableAsync()).Where(t => ids.Contains(t.Id)).ToListAsync(); } public async Task DecreaseUsageCountOfTagsAsync(List ids, CancellationToken cancellationToken = default) { - var tags = await GetMongoQueryable() + var tags = await (await GetMongoQueryableAsync()) .Where(t => ids.Contains(t.Id)) .ToListAsync(GetCancellationToken(cancellationToken)); diff --git a/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Users/MongoBlogUserRepository.cs b/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Users/MongoBlogUserRepository.cs index a0b7655946..fdcf4d0097 100644 --- a/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Users/MongoBlogUserRepository.cs +++ b/modules/blogging/src/Volo.Blogging.MongoDB/Volo/Blogging/Users/MongoBlogUserRepository.cs @@ -17,7 +17,7 @@ namespace Volo.Blogging.Users public async Task> GetUsersAsync(int maxCount, string filter, CancellationToken cancellationToken) { - var query = GetMongoQueryable(); + var query = await GetMongoQueryableAsync(cancellationToken); if (!string.IsNullOrWhiteSpace(filter)) {