Linq-to-Entities Left JOIN

前端 未结 7 774
终归单人心
终归单人心 2021-01-12 09:02

This is my query:

from forum in Forums
    join post in Posts on forum equals post.Forum into postGroup    

    from p in postGroup     
    where p.ParentP         


        
7条回答
  •  囚心锁ツ
    2021-01-12 09:08

     var allforums = from f in context.Fora.Include("Posts")
                               select f;
    

    This query produces the same results as

                var allForums = from f in context.Fora  
                                select new ForumPosts  
                                {  
                                    Forum = f,  
                                    Posts = context.Posts.Where(x=> x.ForumId == f.ForumId)  
    

提交回复
热议问题