title: Lambda Left Join
body: <p>I have a LINQ query and I would like to handle the NULL values after performing a left join. </p>
  
  <p>I have the code below:</p>
  
  <pre><code>var leftjoinlist = listA.GroupJoin(
          listB,
          a =&gt; a.Code,
          b =&gt; b.Code,
          (a, g) =&gt; g
      .SelectMany(new { Parent = a, Child = b })
      .DefaultIfEmpty(new { Parent = a, Child = a }))
      .SelectMany(g =&gt; g).ToList();
  </code></pre>
  
  <p>If child is null, I want to assign the parent instead. However I am getting a conversion error during assignment. Is there a way to do this?</p>