Join Operations

Join Operations


A join of two data sources is the association of objects in one data source with objects that share a common attribute in another data source.

Joining is an important operation in queries that target data sources whose relationships to each other cannot be followed directly. In object-oriented programming, this could mean a correlation between objects that is not modeled, such as the backwards direction of a one-way relationship. An example of a one-way relationship is a Customer class that has a property of type City, but the City class does not have a property that is a collection of Customer objects. If you have a list of City objects and you want to find all the customers in each city, you could use a join operation to find them.

The join methods provided in the LINQ framework are Join<TOuter, TInner, TKey, TResult> and GroupJoin<TOuter, TInner, TKey, TResult>. These methods perform equijoins, or joins that match two data sources based on equality of their keys. (For comparison, Transact-SQL supports join operators other than 'equals', for example the 'less than' operator.) In relational database terms, Join<TOuter, TInner, TKey, TResult> implements an inner join, a type of join in which only those objects that have a match in the other data set are returned. The GroupJoin<TOuter, TInner, TKey, TResult> method has no direct equivalent in relational database terms, but it implements a superset of inner joins and left outer joins. A left outer join is a join that returns each element of the first (left) data source, even if it has no correlated elements in the other data source.

The following illustration shows a conceptual view of two sets and the elements within those sets that are included in either an inner join or a left outer join.

Two overlapping circles showing inner/outer.

Method Name


C# Query Expression Syntax

Visual Basic Query Expression Syntax

More Information


Joins two sequences based on key selector functions and extracts pairs of values.

join … in … on … equals …

From x In …, y In … Where x.a = y.a


Join … [As …]In … On …

Enumerable.Join<TOuter, TInner, TKey, TResult>

Queryable.Join<TOuter, TInner, TKey, TResult>


Joins two sequences based on key selector functions and groups the resulting matches for each element.

join … in … on … equals … into …

Group Join … In … On …

Enumerable.GroupJoin<TOuter, TInner, TKey, TResult>

Queryable.GroupJoin<TOuter, TInner, TKey, TResult>

© 2015 Microsoft