2016-07-27 52 views
0
var allData = (from t1 in table1 
       join t2 in table2 
       on t1.Column1 equals t2.Column1 
       join t3 in table3 
       on t1.Column1.ToString() equals t3.Column1 
       join t4 in table4 
       on t3.Column1 equals t4.Column1 
       join t6 in table4 
       on t1.Column1 equals t6.Column1 
       join t5 in table5 
       on  new { X1 = t4.Column1, X2 = t4.Column2 } 
       equals new { X1 = t5.Column1, X2 = t5.Column1 } 

我有同樣的表table4兩次,但我如何使用equals從不同的表,就像我做了什麼爲table5如何在多個表中的列之間的聯接相當於使用LINQ

+3

你的問題不清楚你問 –

回答

1

您可以使用Where條款,如果你不想指定兩次表4:

var allData = (from t1 in table1 
       join t2 in table2 
       on t1.Column1 equals t2.Column1 
       join t3 in table3 
       on t1.Column1.ToString() equals t3.Column1 
       join t4 in table4 
       on t3.Column1 equals t4.Column1 
       join t5 in table5 
       on new { X1 = t4.Column1, X2 = t4.Column2 } 
       equals new { X1 = t5.Column1, X2 = t5.Column1 } 
       where t1.Column1 == t4.Column1 
       select ....