0

我有一个包含以下数据的数据表。

Table 1
    880000000010747
    880000000012235
    880000000000010
    880000000015086
    880000000000028        
Table 2
    880000000014718
    880000000014928
    880000000009684
    880000000013184
    880000000010747

我如何合并表格并返回下面的结果?

    880000000010747
    880000000012235
    880000000000010
    880000000015086
    880000000000028
    880000000014718
    880000000014928
    880000000009684
    880000000013184
4

1 回答 1

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

希望有帮助。

于 2013-07-25T09:05:31.243 回答