C# – linq to entites left outer join

cleft-joinlinq-to-entities

I am struggling linq to entities left outer join. I have two entities (tables):

Listings 
{
    ListingID,
    MakeID (nullable)
}

Makes
{
    MakeID,
    Description
}

I want to write something like this in LINQ:

select listings.listingID
,listings.makeid
, IsNull(makes.Description, 'NA')
from listings
left outer join makes
on listings.makeid = makes.makeid

Best Answer

Anybody who tells you to use .DefaultIfEmpty() as part of an outer join in LINQ to Entities hasn't actually tried it themselves! Tt simply does not work - at least as at .NET 3.5 SP1.

This blogger tells you how you should actually do it. Essentially, .NET does outer joins in LINQ to Entities by default, so you should leave out the .DefaultIfEmpty(). For multiple outer joins you have to nest the query groups to keep their context clear.