title: Full outer join Linq
body: <p>I do left join and right join then do union for full outer join here is my code</p>
  
  <pre><code>var brndT = (from a in db.TSA_TARGET_DETAIL 
                           where a.OUTLET_ID == id &amp;&amp; a.CAMPAIGN_ID == campaignId &amp;&amp; a.EMPLOYEE_ID == empId 
                           select new 
                           {
                               ID=a.BRAND_ID,
                               Target=a.STICK_QTY
                           }).ToList();
  
              var brndS = (from p in db.SR_TRN_DETAILS
                        where
                            (from ppt in db.SR_TRN_MAIN
                             where
                             ppt.MEMO_DATE &gt;= d2 &amp;&amp; ppt.MEMO_DATE &lt;= d1 &amp;&amp; ppt.OUTLET_ID==id 
                             select ppt.ORDER_ID).Contains(p.ORDER_ID)
                        group p by p.BRAND_ID into g
                        select new
                        {
                            ID = g.Key,
                            Qty = g.Select(x =&gt; x.QUANTITY).Sum()
                        }).ToList();
              var left = (from T in brndT
                         join S in brndS
                         on T.ID equals S.ID
                         into temp
                         from S in temp.DefaultIfEmpty()
                         select new BrandSalesTarget
                         {
                             ID=T.ID,
                             Target = T.Target==null?0:(int)T.Target,
                             Sales = S != null ? (int)S.Qty : 0,
                         }).ToList();
              var right = (from S in brndS
                           join T in brndT
                           on S.ID equals T.ID
                           into temp
                           from T in temp.DefaultIfEmpty()
                           select new BrandSalesTarget
                           {
                               ID=S.ID,
                               Sales = S.Qty==null?0:(int)S.Qty,
                               Target = T != null ? (int)T.Target : 0
                           }).ToList();
              var fullOuter = left.Union(right).ToList();
  </code></pre>
  
  <p>But union does not work. I get the same id twice. What's wrong with my code? Anyone helps is greatly appreciated. Thanks in advance.</p>