In Entity Framework Core (EF.core
) you can use .ThenInclude
for including next levels.
var blogs = context.Blogs
.Include(blog => blog.Posts)
.ThenInclude(post => post.Author)
.ToList();
More information: https://docs.microsoft.com/en-us/ef/core/querying/related-data
Note:
Say you need multiple ThenInclude()
on blog.Posts
, just repeat the Include(blog => blog.Posts)
and do another ThenInclude(post => post.Other)
.
var blogs = context.Blogs
.Include(blog => blog.Posts)
.ThenInclude(post => post.Author)
.Include(blog => blog.Posts)
.ThenInclude(post => post.Other)
.ToList();