Question: 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. 

**UPDATE** 

The result set should be some thing like that:

```
ForumId | ForumTitle | LastPostTitle | LastPostAddedDate  
--------+------------+---------------+------------------
4       |   Sport    |    blabla     |       12/4/2010  
4       |   Sport    |    blabla     |       15/4/2010  
6       |   Games    |    blabla     |       1/5/2010  
7       |   Flame    |               |

```

Answer: 
Try something like this:

```
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 = postGroup.FirstOrDefault(p => p.ParentPostID==0).Title, 
    LastPostAddedDate = (DateTime?)postGroup.FirstOrDefault(p => p.ParentPostID==0).AddedDate          
}).OrderBy(o=>o.ForumID)

```

properties that return empty from the left join must also be nullable. So int => int? and DateTime => DateTime? etc..
```
 public class ForumPosts 
    {
        public Forum Forum { get; set; }
        public IQueryable<Post> Posts { get; set; }
    }

    public class DisplaySet 
    {
        public string Name { get; set; }
        public string PostTile { get; set; }
    } 

          //left outer join
            using (ClassLibrary1.Entities context = new Entities())
            {
                var allForums = from f in context.Fora
                                select new ForumPosts
                                {
                                    Forum = f,
                                    Posts = context.Posts.Where(x=> x.ForumId == f.ForumId)

                                };
                List<DisplaySet> ds = new List<DisplaySet>();

                foreach (var forum in allForums)
                {
                    if (forum.Posts.AsEnumerable().Count() != 0)
                    {
                        foreach (var post in forum.Posts)
                        {
                           ds.Add(new DisplaySet(){ Name = forum.Forum.Name, PostTile = post.PostValue});
                        }
                    }
                    else
                        ds.Add(new DisplaySet(){ Name = forum.Forum.Name, PostTile = string.Empty});
                }

                foreach (var item in ds)
                {
                    Console.WriteLine(string.Format("{0} || {1}",item.Name,item.PostTile));
                }

            }

//This produces the following LINQ query which is right
SELECT 
[Project1].[ForumId] AS [ForumId], 
[Project1].[Name] AS [Name], 
[Project1].[C1] AS [C1], 
[Project1].[PostId] AS [PostId], 
[Project1].[PostValue] AS [PostValue], 
[Project1].[ForumId1] AS [ForumId1]
FROM ( SELECT 
    [Extent1].[ForumId] AS [ForumId], 
    [Extent1].[Name] AS [Name], 
    [Extent2].[PostId] AS [PostId], 
    [Extent2].[PostValue] AS [PostValue], 
    [Extent2].[ForumId] AS [ForumId1], 
    CASE WHEN ([Extent2].[PostId] IS NULL) THEN CAST(NULL AS int) ELSE 1 END AS [C1]
    FROM  [dbo].[Forum] AS [Extent1]
    LEFT OUTER JOIN [dbo].[Post] AS [Extent2] ON [Extent2].[ForumId] = [Extent1].[ForumId]
)  AS [Project1]
ORDER BY [Project1].[ForumId] ASC, [Project1].[C1] ASC

```