From 481e24db06823cdee057cffb36d703777910c09d Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Fri, 8 Feb 2019 08:24:29 +0300 Subject: [PATCH] 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(); + } } }