ALinq

Linq To Access, MS SQL, SQLite, MySQL, Oracle, Firebird, DB2, PostgreSQL ......

ALinq Document > Programming Guide > Querying the Database > Query Examples

Return the Set Difference Between Two Sequences

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

Example

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)
    .Except
        (from emp in db.Employees
        select emp.Country);
Dim infoQuery = _
    (From cust In db.Customers _
    Select cust.Country) _
    .Except _
        (From emp In db.Employees _
        Select emp.Country)