From 481e24db06823cdee057cffb36d703777910c09d Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Fri, 8 Feb 2019 08:24:29 +0300 Subject: [PATCH 1/2] added BloggingEntityFrameworkCoreQueryableExtensions --- ...gEntityFrameworkCoreQueryableExtensions.cs | 20 +++++++++++++++++++ .../Blogging/Posts/EfCorePostRepository.cs | 6 ++++++ 2 files changed, 26 insertions(+) create mode 100644 modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/BloggingEntityFrameworkCoreQueryableExtensions.cs 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(); + } } } From a874171a590992ba3f11e2d41698cb94bb0f3e4f Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Fri, 8 Feb 2019 08:24:38 +0300 Subject: [PATCH 2/2] typo fix --- .../Volo/Blogging/PostAppService_Tests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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);