鉴于:
TABLE_1
具有以下列的列命名的表:
ID
ColumnA
ColumnB
ColumnC
我有SQL查询,其中TABLE_1
基于关闭的两次自己加入ColumnA
,ColumnB
,ColumnC
。该查询可能看起来像这样:
Select t1.ID, t2.ID, t3.ID
From TABLE_1 t1
Left Join TABLE_1 t2 On
t1.ColumnA = t2.ColumnA
And t1.ColumnB = t2.ColumnB
And t1.ColumnC = t2.ColumnC
Left Join TABLE_1 t3 On
t2.ColumnA = t3.ColumnA
And t2.ColumnB = t3.ColumnB
And t2.ColumnC = t3.ColumnC
... and query continues on etc.
问题:
我需要在LINQ中重写该查询。我试着刺了一下:
var query =
from t1 in myTABLE1List // List<TABLE_1>
join t2 in myTABLE1List
on t1.ColumnA equals t2.ColumnA
&& t1.ColumnB equals t2.ColumnA
// ... and at this point intellisense is making it very obvious
// I am doing something wrong :(
如何在LINQ中编写查询?我究竟做错了什么?