diff --git a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/BloggingEntityFrameworkCoreQueryableExtensions.cs b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/BloggingEntityFrameworkCoreQueryableExtensions.cs new file mode 100644 index 0000000000..2b9caa6c85 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/BloggingEntityFrameworkCoreQueryableExtensions.cs @@ -0,0 +1,20 @@ +using Volo.Blogging.Posts; +using System.Linq; +using Microsoft.EntityFrameworkCore; + +namespace Volo.Blogging +{ + public static class BloggingEntityFrameworkCoreQueryableExtensions + { + public static IQueryable IncludeDetails(this IQueryable queryable, bool include = true) + { + if (!include) + { + return queryable; + } + + return queryable + .Include(x => x.Tags); + } + } +} 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 58a3c83413..3605550ac4 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 @@ -7,6 +7,7 @@ using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using Volo.Blogging.EntityFrameworkCore; +using System.Linq.Dynamic.Core; namespace Volo.Blogging.Posts { @@ -34,5 +35,10 @@ namespace Volo.Blogging.Posts return post; } + + public override IQueryable WithDetails() + { + return GetQueryable().IncludeDetails(); + } } } diff --git a/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/PostAppService_Tests.cs b/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/PostAppService_Tests.cs index ec4210446c..260304d6ba 100644 --- a/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/PostAppService_Tests.cs +++ b/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/PostAppService_Tests.cs @@ -29,7 +29,7 @@ namespace Volo.Blogging } [Fact] - public async Task Should_Get_Fore_Reading() + public async Task Should_Get_For_Reading() { var blogId = (await _blogRepository.GetListAsync()).First().Id; var post = (await _postRepository.GetListAsync()).First(p=>p.BlogId == blogId);