我有两个数据表,所有字段都是字符串:
Table1
Branch
AccountNumber
Name
Address
City
State
Zip
Table2
Branch
AccountNumber
Address2
City2
State2
Zip2
我需要通过分支列和帐号列将两个表连接在一起,最后得到一个包含所有列的表。
我在另一篇文章中发现了这个并且无法解决细节问题:
var collection = from t1 in iom.DataTable.AsEnumerable()
join t2 in iob.DataTable.AsEnumerable()
on t1["Branch"] equals t2["Branch"] &
t1["AccountNumber"] equals t2["AccountNumber"]
select new { Branch = t1["Branch"], AccountNumber = t2["AccountNumber"] };
我有两个问题:
感谢您的帮助!
答案 0 :(得分:1)
&
运营商。您应该将查询重写为
var collection = from t1 in iom.DataTable.AsEnumerable()
join t2 in iob.DataTable.AsEnumerable()
on new { Branch = t1["Branch"], AccountNumber = t1["AccountNumber"] } equals
new { Branch = t2["Branch"], AccountNumber = t2["AccountNumber"] }
select new { Branch = t1["Branch"], AccountNumber = t2["AccountNumber"] };