title: Using LINQ in cross-join query of a datatable in C#
body: <p>I have an issue with using LINQ for cross-join query of a dataTable.</p>
  
  <pre><code>DataTable dt_edges = new DataTable();
  dt_edges.Columns.Add("EdgeID", typeof(string));
  dt_edges.Columns.Add("TriangleID", typeof(string));
  dt_edges.Columns.Add("StartPointID", typeof(string));
  dt_edges.Columns.Add("EndPointID", typeof(string));
  dt_edges.Columns.Add("StartVerticeX", typeof(double));
  dt_edges.Columns.Add("StartVerticeY", typeof(double));
  dt_edges.Columns.Add("StartVerticeZ", typeof(double));
  dt_edges.Columns.Add("EndVerticeX", typeof(double));
  dt_edges.Columns.Add("EndVerticeY", typeof(double));
  dt_edges.Columns.Add("EndVerticeZ", typeof(double));
  
  
  var q = from a in dt_edges.AsEnumerable()
  from b in dt_edges.AsEnumerable()
  
  where (
  a["StartVerticeX"].ToString() == b["StartVerticeX"].ToString()
  &amp;&amp; a["StartVerticeY"].ToString() == b["StartVerticeY"].ToString()
  &amp;&amp; a["EndVerticeX"].ToString() == b["EndVerticeX"].ToString()
  &amp;&amp; a["EndVerticeY"].ToString() == b["EndVerticeY"].ToString()
  )
  
  select new { 
  edgeID = a["EdgeID"],
  aSVX = a["StartVerticeX"], 
  aSVY = a["StartVerticeY"],
  bSVZ = b["StartVerticeX"], 
  bSVY = b["StartVerticeY"]
  };
  
  foreach (var item in q)
  {
  textBox2.Text += item.edgeID.ToString() + ": " + item.aSVX.ToString() + " " + item.aSVY.ToString() + ", " + item.bSVZ.ToString() + " " + item.bSVY.ToString() + "\n";
  }
  </code></pre>
  
  <p>When I run the code, I have only 5 records in the dataTable, but the results of the count of the q is 225! 
  When I check the results there are multiple repeats of the joined records and it seems that the filter does not really work properly.</p>
  
  <p>What I'd like to do is to filter only those that have the StartX and StartY as well as EndX and EndY of the same in the dataTable. However, I haven't been able to resolve the issue.</p>
  
  <p>Looking forward to your help.
  Cheers.</p>