Click to Rate and Give Feedback

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Language-Integrated Query (LINQ)
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 and GroupJoin. 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 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 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

Description

C# Query Expression Syntax

Visual Basic Query Expression Syntax

More Information

Join

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 = b.a

-or-

Join … [As …]In … On …

Enumerable..::.Join

Queryable..::.Join

GroupJoin

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

Queryable..::.GroupJoin

TopicLocation
How to: Join by Using Composite KeysC# Programmer's Reference
How to: Join by Using Composite KeysC# Programmer's Reference
How to: Join Content from Dissimilar Files (LINQ)Language-Integrated Query (LINQ)
How to: Join Content from Dissimilar Files (LINQ)Language-Integrated Query (LINQ)
How to: Order the Results of a Join ClauseC# Programmer's Reference
How to: Order the Results of a Join ClauseC# Programmer's Reference
How to: Perform Custom Join OperationsC# Programmer's Reference
How to: Perform Custom Join OperationsC# Programmer's Reference
How to: Perform Grouped JoinsC# Programmer's Reference
How to: Perform Grouped JoinsC# Programmer's Reference
How to: Perform Inner JoinsC# Programmer's Reference
How to: Perform Inner JoinsC# Programmer's Reference
How to: Perform Left Outer JoinsC# Programmer's Reference
How to: Perform Left Outer JoinsC# Programmer's Reference
How to: Populate Object Collections from Multiple Sources (LINQ)Language-Integrated Query (LINQ)
How to: Populate Object Collections from Multiple Sources (LINQ)Language-Integrated Query (LINQ)
join clauseC# Programmer's Reference
join clauseC# Programmer's Reference

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker