title: Left Outer Join Two Data Tables?
body: <p>Is it possible to modify this LINQ method to perform a left outer join?  Looking at LINQ queries, I'm in way over my head..</p>
  
  <pre><code>Private Function MergeTables(Of T)(ByVal dtForecast As DataTable, 
                                   ByVal dtDns As DataTable, _
                                   ByVal fieldASelector As Func(Of DataRow, T), _
                                   ByVal fieldBSelector As Func(Of DataRow, T), _
                                   ByVal whereClauseA As Func(Of DataRow, Decimal), _
                                   ByVal whereClauseB As Func(Of DataRow, Decimal))
    Dim test = (From forecast In dtForecast.AsEnumerable() Join dns In dtDns.AsEnumerable() _
                On fieldASelector(forecast) Equals fieldBSelector(dns) _
                Where whereClauseA(forecast) &lt;&gt; 0 And whereClauseB(dns) &lt;&gt; 0 _
              Select New With _
                  { _
                      .ProductId = forecast.Field(Of String)("ProductID"), _
                      .Product = forecast.Field(Of String)("ProductName"), _
                      .Account = forecast.Field(Of String)("Account"), _
                      .BrandName = forecast.Field(Of String)("BrandName"), _
                      .CorrugateCost = forecast.Field(Of Decimal)("Corrugate_Cost"), _
                      .f_m1 = forecast.Field(Of Decimal)("f_m1"), _
                      .a_m1 = dns.Field(Of Decimal)("a_m1"), _
                      .f_m2 = forecast.Field(Of Decimal)("f_m2"), _
                      .a_m2 = dns.Field(Of Decimal)("a_m2"), _
                      .f_m3 = forecast.Field(Of Decimal)("f_m3"), _
                      .a_m3 = dns.Field(Of Decimal)("a_m3"), _
                      .f_m4 = forecast.Field(Of Decimal)("f_m4"), _
                      .a_m4 = dns.Field(Of Decimal)("a_m4"), _
                      .f_m5 = forecast.Field(Of Decimal)("f_m5"), _
                      .a_m5 = dns.Field(Of Decimal)("a_m5"), _
                      .f_m6 = forecast.Field(Of Decimal)("f_m6"), _
                      .a_m6 = dns.Field(Of Decimal)("a_m6"), _
                      .f_m7 = forecast.Field(Of Decimal)("f_m7"), _
                      .a_m7 = dns.Field(Of Decimal)("a_m7"), _
                      .f_m8 = forecast.Field(Of Decimal)("f_m8"), _
                      .a_m8 = dns.Field(Of Decimal)("a_m8"), _
                      .f_m9 = forecast.Field(Of Decimal)("f_m9"), _
                      .a_m9 = dns.Field(Of Decimal)("a_m9"), _
                      .f_m10 = forecast.Field(Of Decimal)("f_m10"), _
                      .a_m10 = dns.Field(Of Decimal)("a_m10"), _
                      .f_m11 = forecast.Field(Of Decimal)("f_m11"), _
                      .a_m11 = dns.Field(Of Decimal)("a_m11"), _
                      .f_m12 = forecast.Field(Of Decimal)("f_m12"), _
                      .a_m12 = dns.Field(Of Decimal)("a_m12"), _
                      .f_total = forecast.Field(Of Decimal)("f_total"), _
                      .a_total = dns.Field(Of Decimal)("a_total") _
                  }).ToList()
  
          Return test
      End Function
  </code></pre>