title: VB.Net LINQ - left outer join between two datatables - limit to one row
body: <p>I have an issue with LINQ in vb.net. Basically I want create LEFT JOIN between two datatables.</p>
  
  <p>This is the info of the two datatables:</p>
  
  <pre><code>Dim vDT1 As New DataTable
  vDT1.Columns.Add("Key")
  vDT1.Columns.Add("Data1")
  vDT1.Columns.Add("Data2")
  
  vDT1.Rows.Add({"01", "DATA1_AAAA", "DATA2_AAAA"})
  vDT1.Rows.Add({"02", "DATA1_BBBB", "DATA2_BBBB"})
  
  Dim vDT2 As New DataTable
  vDT2.Columns.Add("Key")
  vDT2.Columns.Add("Data3")
  vDT2.Columns.Add("Data4")
  
  vDT2.Rows.Add({"01", "DATA3_AAAA", "DATA4_AAAA"})
  vDT2.Rows.Add({"01", "DATA3_BBBB", "DATA4_BBBB"})
  vDT2.Rows.Add({"01", "DATA3_CCCC", "DATA4_CCCC"})
  vDT2.Rows.Add({"01", "DATA3_DDDD", "DATA4_DDDD"})
  
  Dim vDRnull As DataRow = vDTsec.Rows.Add
  </code></pre>
  
  <p>In order to achieve the LINQ JOIN I try to use the next sentence:</p>
  
  <pre><code>From a In vDT1.AsEnumerable
  Group Join bTemp In vDT2.AsEnumerable
  On a.Field(Of String)("Key") Equals bTemp.Field(Of String)("Key")
  Into Group From b In Group.DefaultIfEmpty(vDRnull)
  Select a, b
  </code></pre>
  
  <p>This is the result (but I want remove the red rows), I only want get the first occurrence in the second table:</p>
  
  <p><img src="https://i.stack.imgur.com/6t7ba.png" alt="Issue 1"></p>
  
  <p>Any help will be appreciated!</p>
  
  <hr>
  
  <p>I edit the question with the correct method. Thanks to Jeff Mercado:</p>
  
  <pre><code>Dim vDT1 As New DataTable
  vDT1.Columns.Add("Key")
  vDT1.Columns.Add("Data1")
  vDT1.Columns.Add("Data2")
  
  vDT1.Rows.Add({"01", "DATA1_AAAA", "DATA2_AAAA"})
  vDT1.Rows.Add({"02", "DATA1_BBBB", "DATA2_BBBB"})
  
  Dim vDT2 As New DataTable
  vDT2.Columns.Add("Key")
  vDT2.Columns.Add("Data3")
  vDT2.Columns.Add("Data4")
  
  vDT2.Rows.Add({"01", "DATA3_AAAA", "DATA4_AAAA"})
  vDT2.Rows.Add({"01", "DATA3_BBBB", "DATA4_BBBB"})
  vDT2.Rows.Add({"01", "DATA3_CCCC", "DATA4_CCCC"})
  vDT2.Rows.Add({"01", "DATA3_DDDD", "DATA4_DDDD"})
  
  Dim vDRnull As DataRow = vDT2.Rows.Add
  
  Dim vLINQ = From a In vDT1.AsEnumerable
      Group Join bTemp In vDT2.AsEnumerable
      On a.Field(Of Object)("Key") Equals bTemp.Field(Of Object)("Key")
      Into Group Let b = If(Group.FirstOrDefault Is Nothing, vDRnull, Group.FirstOrDefault)
      Select a, b
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/AW8Ji.png" alt="enter image description here"></p>