Linq-to-Entities Left JOIN

Posted by shivesh on Stack Overflow See other posts from Stack Overflow or by shivesh
Published on 2010-05-05T09:39:02Z Indexed on 2010/05/05 10:08 UTC
Read the original article Hit count: 307

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.ParentPostID==0

    select new 
    {
        forum.Title,
        forum.ForumID,  
        LastPostTitle = p.Title,
        LastPostAddedDate = p.AddedDate         
    }).OrderBy(o=>o.ForumID) 

Currently the Join is not left join, meaning if some forum doesn't have a post that belongs to it, it will not be returned.
The forum without posts must be returned with null (or default) values for the post properties.

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about linq-to-entities