2013-03-05 33 views
0

如何返回的所有列在下面的匿名LINQ加入:返回匿名LINQ中的所有列加入

var results = (from t in Table1.AsEnumerable() join t2 in Table2.AsEnumerable() 
       on t.Field<string>("id") equals t2.Field<string>("id") 
       into allcol from rows in allcol 
       select rows); 

我得到允許Table2行,並沒有從Table1

回答

1
var results = (from t in Table1.AsEnumerable() 
          join t2 in Table2.AsEnumerable() 
          on t.Field<string>("id") 
          equals t2.Field<string>("id") 
          into allcol 
          from rows in allcol 
          select new {table1=t,table2=rows}); 

我希望這會有所幫助。

+0

這是返回一個數據集還是兩個不同的數據集?當我在調試器中看到它時,它似乎將它們分開了? – 2013-03-05 15:48:34

+0

是的,你需要遍歷並將它們轉換爲匿名類型的特定類型。 – ethicallogics 2013-03-05 15:55:58