Conditional Include() in Entity Framework

前端 未结 8 2012
暗喜
暗喜 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条回答
  •  猫巷女王i
    2020-11-28 09:21

    EF Core 5.0 is introducing Filtered Include soon.

    var blogs = context.Blogs
        .Include(e => e.Posts.Where(p => p.Title.Contains("Cheese")))
        .ToList();
    

    Reference: https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-5.0/whatsnew#filtered-include

提交回复
热议问题