We have the following EF code:
var qry =
from c in db.Contacts
join comp in db.Companies on c.CompanyId equals comp.CompanyId
into compLeft
from cj in compLeft.DefaultIfEmpty()
select new CompleteUserDlModel
{
CompanyName = cj.Company1,
CompanyId = c.CompanyId
};
which generates this SQL
SELECT
[Extent1].[CompanyId] AS [CompanyId],
[Extent2].[Company] AS [Company]
FROM [dbo].[Contacts] AS [Extent1]
INNER JOIN [dbo].[Company] AS [Extent2] ON [Extent1].[CompanyId] = [Extent2].[CompanyId]
but we actually want
SELECT
[Extent1].[CompanyId] AS [CompanyId],
[Extent2].[Company] AS [Company]
FROM [dbo].[Contacts] AS [Extent1]
LEFT OUTER JOIN [dbo].[Company] AS [Extent2] ON [Extent1].[CompanyId] = [Extent2].[CompanyId]
Could someone point out what we've done wrong, please?
All the refs on left outer joins in C# EF (i.e. LEFT OUTER JOIN in LINQ) point to the syntax we're using. Clearly, we're missing something.