ALinq

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

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

Return the Set Intersection of Two Sequences

Use the Intersect operator to return the set intersection of two sequences.

Example

This example uses Intersect to return a sequence of all countries in which both Customers and Employees live.
var infoQuery =
    (from cust in db.Customers
    select cust.Country)
    .Intersect
        (from emp in db.Employees
        select emp.Country);
Dim infoQuery = _
    (From cust In db.Customers _
    Select cust.Country) _
    .Intersect _
        (From emp In db.Employees _
        Select emp.Country)