Conditional Include() in Entity Framework

前端 未结 8 1995
暗喜
暗喜 2020-11-28 09:03

I have seen a few answers to similar questions, however I cannot seem to work out how to apply the answer to my issue.

var allposts = _context.Posts
                 


        
8条回答
  •  执念已碎
    2020-11-28 09:11

    try this

    var allposts = _context.Posts
            .Include(p => p.Comments)
            .Include(a => a.PostAuthor)
            .Where(t => t.PostAuthor.Id == postAuthorId).ToList();
    
    _context.Attachments.Where(o=>o.Owner is Author).ToList();
    

提交回复
热议问题