Browse Source

Merge pull request #8 from abpframework/master

merge
pull/786/head
Marcelo Mohr Maciel 7 years ago
committed by GitHub
parent
commit
8b03f40911
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/BloggingEntityFrameworkCoreQueryableExtensions.cs
  2. 6
      modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Posts/EfCorePostRepository.cs
  3. 2
      modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/PostAppService_Tests.cs

20
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<Post> IncludeDetails(this IQueryable<Post> queryable, bool include = true)
{
if (!include)
{
return queryable;
}
return queryable
.Include(x => x.Tags);
}
}
}

6
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<Post> WithDetails()
{
return GetQueryable().IncludeDetails();
}
}
}

2
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);

Loading…
Cancel
Save