我有一个包含以下数据的数据表。
Table 1
880000000010747
880000000012235
880000000000010
880000000015086
880000000000028
Table 2
880000000014718
880000000014928
880000000009684
880000000013184
880000000010747
我如何结合表并返回下面的结果?
880000000010747
880000000012235
880000000000010
880000000015086
880000000000028
880000000014718
880000000014928
880000000009684
880000000013184
答案 0 :(得分:0)
从.Net 3.5到4.5(写作时),您可以使用Union方法
http://msdn.microsoft.com/en-us/library/bb386993(v=vs.110).aspx
C#示例:
var infoQuery =
(from cust in db.Customers
select cust.Country)
.Union
(from emp in db.Employees
select emp.Country)
;
VB.net示例:
Dim infoQuery = _
(From cust In db.Customers _
Select cust.Country) _
.Union _
(From emp In db.Employees _
Select emp.Country)
如果您要加入所有重复项,请查看Concat方法:
http://code.msdn.microsoft.com/LINQ-Miscellaneous-6b72bb2a#Concat1
希望有所帮助。