title: Left outer join in C# LINQ
body: <p><strong>LINQ query</strong></p>
  
  <pre><code>from rc in context.RC
  join r in context.R on rc.RId equals r.Id 
  join c in context.C on rc.CId equals c.Id 
  join f in context.F on rc.FId equals f.Id into fg
  from f in fg.DefaultIfEmpty()
  join e in context.E on rc.EId equals e.Id into eg
  from e in eg.DefaultIfEmpty()
  </code></pre>
  
  <p><strong>Generated SQL is</strong></p>
  
  <pre><code>SELECT  *
  FROM    [dbo].[RC] AS [Extent1]
          INNER JOIN [dbo].[R] AS [Extent2] ON [Extent1].[RId] = [Extent2].[Id]
          INNER JOIN [dbo].[C] AS [Extent3] ON [Extent1].[CId] = [Extent3].[Id]
          INNER JOIN [dbo].[F] AS [Extent4] ON [Extent1].[FId] = [Extent4].[Id]
          INNER JOIN [dbo].[E] AS [Extent5] ON [Extent1].[EId] = [Extent5].[Id]
  </code></pre>
  
  <p><strong>What I want to get is</strong></p>
  
  <pre><code>SELECT  *
  FROM    [dbo].[RC] AS [Extent1]
          INNER JOIN [dbo].[R] AS [Extent2] ON [Extent1].[RId] = [Extent2].[Id]
          INNER JOIN [dbo].[C] AS [Extent3] ON [Extent1].[CId] = [Extent3].[Id]
          LEFT JOIN [dbo].[F] AS [Extent4] ON [Extent1].[FId] = [Extent4].[Id]
          LEFT JOIN [dbo].[E] AS [Extent5] ON [Extent1].[EId] = [Extent5].[Id]
  </code></pre>
  
  <p>Not sure what am I missing in my LINQ query</p>
  
  <p><strong>Screen Shot of the code</strong></p>
  
  <p><a href="https://i.stack.imgur.com/4YGvM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4YGvM.png" alt="enter image description here"></a></p>
  
  <p><strong>Update</strong></p>
  
  <p>Based upon comment by @GertArnold, <code>RC-F</code> (tables) and <code>RC-E</code> (tables) are in <code>N-1</code> association, where <code>RC</code> should hold a valid id key reference for <code>F</code>, but in <code>RC</code> table, some <code>F</code> <strong>ids are zeros</strong>, which is skipping data when I do <code>inner join</code>. </p>
  
  <p>So now how can I force Entity-Framework/LINQ to generate <code>LEFT JOIN</code> syntax without modifying my DB schema</p>