1 out of 2 rated this helpful - Rate this topic

Return the Set Union of Two Sequences

Use the Union operator to return the set union of two sequences.

Example

This example uses Union to return a sequence of all countries in which there are either Customers or Employees.

var infoQuery =
    (from cust in db.Customers
    select cust.Country)
    .Union
        (from emp in db.Employees
        select emp.Country)
;

In LINQ to SQL, the Union operator is defined for multisets as the unordered concatenation of the multisets (effectively the result of the UNION ALL clause in SQL).

See Also



Copyright © 2012 by Microsoft Corporation. All rights reserved.


Build Date:

2012-08-02
Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.