This documentation is archived and is not being maintained.

How to: Return the Set Difference Between Two Sequences (LINQ to SQL)

Use the Except operator to return the set difference between two sequences.

This example uses Except to return a sequence of all countries in which Customers live but in which no Employees live.

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

In LINQ to SQL, the Except operation is well defined only on sets. The semantics for multisets is undefined.