简体   繁体   中英

EF 6 load nested entities

I have nested entites like example from msdn .

var blogs1 = context.Blogs 
                   .Include(b => b.Posts.Select(p => p.Comments)) 
                   .ToList(); 

But in my case, Comment have structure like this:

public class Comment
{
    public List<User> ViewedUsers { get; set; };
}

How can i load ViewedUsers in this case, if method .ThenInclude() is unavalable? I mean new layer of nested entites.

In this case i need to use next statement:

var blogs1 = context.Blogs 
               .Include(b => b.Posts.Select(p => p.Comments.Select(cm => cm.ViewedUsers))) 
               .ToList(); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM