Merge pull request #8 from abpframework/master

merge
pull/786/head
Marcelo Mohr Maciel 6 years ago committed by GitHub
commit 8b03f40911
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,20 @@
using Volo.Blogging.Posts;
using System.Linq;
using Microsoft.EntityFrameworkCore;
namespace Volo.Blogging
{
public static class BloggingEntityFrameworkCoreQueryableExtensions
{
public static IQueryable<Post> IncludeDetails(this IQueryable<Post> queryable, bool include = true)
{
if (!include)
{
return queryable;
}
return queryable
.Include(x => x.Tags);
}
}
}

@ -7,6 +7,7 @@ using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
using Volo.Blogging.EntityFrameworkCore; using Volo.Blogging.EntityFrameworkCore;
using System.Linq.Dynamic.Core;
namespace Volo.Blogging.Posts namespace Volo.Blogging.Posts
{ {
@ -34,5 +35,10 @@ namespace Volo.Blogging.Posts
return post; return post;
} }
public override IQueryable<Post> WithDetails()
{
return GetQueryable().IncludeDetails();
}
} }
} }

@ -29,7 +29,7 @@ namespace Volo.Blogging
} }
[Fact] [Fact]
public async Task Should_Get_Fore_Reading() public async Task Should_Get_For_Reading()
{ {
var blogId = (await _blogRepository.GetListAsync()).First().Id; var blogId = (await _blogRepository.GetListAsync()).First().Id;
var post = (await _postRepository.GetListAsync()).First(p=>p.BlogId == blogId); var post = (await _postRepository.GetListAsync()).First(p=>p.BlogId == blogId);

Loading…
Cancel
Save