Edit

Share via


Queryable.LeftJoin Method

Definition

Overloads

LeftJoin<TOuter,TInner,TKey,TResult>(IQueryable<TOuter>, IEnumerable<TInner>, Expression<Func<TOuter,TKey>>, Expression<Func<TInner,TKey>>, Expression<Func<TOuter,TInner,TResult>>, IEqualityComparer<TKey>)

Source:
Queryable.cs

Correlates the elements of two sequences based on matching keys. A specified IEqualityComparer<T> is used to compare keys.

public:
generic <typename TOuter, typename TInner, typename TKey, typename TResult>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::IQueryable<TResult> ^ LeftJoin(System::Linq::IQueryable<TOuter> ^ outer, System::Collections::Generic::IEnumerable<TInner> ^ inner, System::Linq::Expressions::Expression<Func<TOuter, TKey> ^> ^ outerKeySelector, System::Linq::Expressions::Expression<Func<TInner, TKey> ^> ^ innerKeySelector, System::Linq::Expressions::Expression<Func<TOuter, TInner, TResult> ^> ^ resultSelector, System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public static System.Linq.IQueryable<TResult> LeftJoin<TOuter,TInner,TKey,TResult>(this System.Linq.IQueryable<TOuter> outer, System.Collections.Generic.IEnumerable<TInner> inner, System.Linq.Expressions.Expression<Func<TOuter,TKey>> outerKeySelector, System.Linq.Expressions.Expression<Func<TInner,TKey>> innerKeySelector, System.Linq.Expressions.Expression<Func<TOuter,TInner?,TResult>> resultSelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer);
static member LeftJoin : System.Linq.IQueryable<'Outer> * seq<'Inner> * System.Linq.Expressions.Expression<Func<'Outer, 'Key>> * System.Linq.Expressions.Expression<Func<'Inner, 'Key>> * System.Linq.Expressions.Expression<Func<'Outer, 'Inner, 'Result>> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Linq.IQueryable<'Result>
<Extension()>
Public Function LeftJoin(Of TOuter, TInner, TKey, TResult) (outer As IQueryable(Of TOuter), inner As IEnumerable(Of TInner), outerKeySelector As Expression(Of Func(Of TOuter, TKey)), innerKeySelector As Expression(Of Func(Of TInner, TKey)), resultSelector As Expression(Of Func(Of TOuter, TInner, TResult)), comparer As IEqualityComparer(Of TKey)) As IQueryable(Of TResult)

Type Parameters

TOuter

The type of the elements of the first sequence.

TInner

The type of the elements of the second sequence.

TKey

The type of the keys returned by the key selector functions.

TResult

The type of the result elements.

Parameters

outer
IQueryable<TOuter>

The first sequence to join.

inner
IEnumerable<TInner>

The sequence to join to the first sequence.

outerKeySelector
Expression<Func<TOuter,TKey>>

A function to extract the join key from each element of the first sequence.

innerKeySelector
Expression<Func<TInner,TKey>>

A function to extract the join key from each element of the second sequence.

resultSelector
Expression<Func<TOuter,TInner,TResult>>

A function to create a result element from two matching elements.

comparer
IEqualityComparer<TKey>

An IEqualityComparer<T> to hash and compare keys.

Returns

IQueryable<TResult>

An IEnumerable<T> that has elements of type TResult that are obtained by performing a left outer join on two sequences.

Exceptions

outer or inner or outerKeySelector or innerKeySelector or resultSelector is null.

Remarks

This method has at least one parameter of type Expression<TDelegate> whose type argument is one of the Func<T,TResult> types.

For these parameters, you can pass in a lambda expression and it will be compiled to an Expression<TDelegate>.

The LeftJoin<TOuter,TInner,TKey,TResult>(IQueryable<TOuter>, IEnumerable<TInner>, Expression<Func<TOuter,TKey>>, Expression<Func<TInner,TKey>>, Expression<Func<TOuter,TInner,TResult>>, IEqualityComparer<TKey>) method generates a MethodCallExpression that represents calling LeftJoin<TOuter,TInner,TKey,TResult>(IQueryable<TOuter>, IEnumerable<TInner>, Expression<Func<TOuter,TKey>>, Expression<Func<TInner,TKey>>, Expression<Func<TOuter,TInner,TResult>>, IEqualityComparer<TKey>) itself as a constructed generic method.

It then passes the MethodCallExpression to the CreateQuery<TElement>(Expression) method of the IQueryProvider represented by the Provider property of the outer parameter.

The query behavior that occurs as a result of executing an expression tree that represents calling LeftJoin<TOuter,TInner,TKey,TResult>(IQueryable<TOuter>, IEnumerable<TInner>, Expression<Func<TOuter,TKey>>, Expression<Func<TInner,TKey>>, Expression<Func<TOuter,TInner,TResult>>, IEqualityComparer<TKey>) depends on the implementation of the type of the outer parameter.

The expected behavior is that of a left outer join.

The outerKeySelector and innerKeySelector functions are used to extract keys from outer and inner, respectively.

These keys are compared for equality to match elements from each sequence.

A pair of elements is stored for each element in inner that matches an element in outer, plus a pair for each element in outer that has no matches in inner.

Then the resultSelector function is invoked to project a result object from each pair of elements.

Applies to

LeftJoin<TOuter,TInner,TKey,TResult>(IQueryable<TOuter>, IEnumerable<TInner>, Expression<Func<TOuter,TKey>>, Expression<Func<TInner,TKey>>, Expression<Func<TOuter,TInner,TResult>>)

Source:
Queryable.cs

Correlates the elements of two sequences based on matching keys. The default equality comparer is used to compare keys.

public:
generic <typename TOuter, typename TInner, typename TKey, typename TResult>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::IQueryable<TResult> ^ LeftJoin(System::Linq::IQueryable<TOuter> ^ outer, System::Collections::Generic::IEnumerable<TInner> ^ inner, System::Linq::Expressions::Expression<Func<TOuter, TKey> ^> ^ outerKeySelector, System::Linq::Expressions::Expression<Func<TInner, TKey> ^> ^ innerKeySelector, System::Linq::Expressions::Expression<Func<TOuter, TInner, TResult> ^> ^ resultSelector);
public static System.Linq.IQueryable<TResult> LeftJoin<TOuter,TInner,TKey,TResult>(this System.Linq.IQueryable<TOuter> outer, System.Collections.Generic.IEnumerable<TInner> inner, System.Linq.Expressions.Expression<Func<TOuter,TKey>> outerKeySelector, System.Linq.Expressions.Expression<Func<TInner,TKey>> innerKeySelector, System.Linq.Expressions.Expression<Func<TOuter,TInner?,TResult>> resultSelector);
static member LeftJoin : System.Linq.IQueryable<'Outer> * seq<'Inner> * System.Linq.Expressions.Expression<Func<'Outer, 'Key>> * System.Linq.Expressions.Expression<Func<'Inner, 'Key>> * System.Linq.Expressions.Expression<Func<'Outer, 'Inner, 'Result>> -> System.Linq.IQueryable<'Result>
<Extension()>
Public Function LeftJoin(Of TOuter, TInner, TKey, TResult) (outer As IQueryable(Of TOuter), inner As IEnumerable(Of TInner), outerKeySelector As Expression(Of Func(Of TOuter, TKey)), innerKeySelector As Expression(Of Func(Of TInner, TKey)), resultSelector As Expression(Of Func(Of TOuter, TInner, TResult))) As IQueryable(Of TResult)

Type Parameters

TOuter

The type of the elements of the first sequence.

TInner

The type of the elements of the second sequence.

TKey

The type of the keys returned by the key selector functions.

TResult

The type of the result elements.

Parameters

outer
IQueryable<TOuter>

The first sequence to join.

inner
IEnumerable<TInner>

The sequence to join to the first sequence.

outerKeySelector
Expression<Func<TOuter,TKey>>

A function to extract the join key from each element of the first sequence.

innerKeySelector
Expression<Func<TInner,TKey>>

A function to extract the join key from each element of the second sequence.

resultSelector
Expression<Func<TOuter,TInner,TResult>>

A function to create a result element from two matching elements.

Returns

IQueryable<TResult>

An IEnumerable<T> that has elements of type TResult that are obtained by performing a left outer join on two sequences.

Exceptions

outer or inner or outerKeySelector or innerKeySelector or resultSelector is null.

Remarks

This method has at least one parameter of type Expression<TDelegate> whose type argument is one of the Func<T,TResult> types.

For these parameters, you can pass in a lambda expression and it will be compiled to an Expression<TDelegate>.

The LeftJoin<TOuter,TInner,TKey,TResult>(IQueryable<TOuter>, IEnumerable<TInner>, Expression<Func<TOuter,TKey>>, Expression<Func<TInner,TKey>>, Expression<Func<TOuter,TInner,TResult>>) method generates a MethodCallExpression that represents calling LeftJoin<TOuter,TInner,TKey,TResult>(IQueryable<TOuter>, IEnumerable<TInner>, Expression<Func<TOuter,TKey>>, Expression<Func<TInner,TKey>>, Expression<Func<TOuter,TInner,TResult>>) itself as a constructed generic method.

It then passes the MethodCallExpression to the CreateQuery<TElement>(Expression) method of the IQueryProvider represented by the Provider property of the outer parameter.

The query behavior that occurs as a result of executing an expression tree that represents calling LeftJoin<TOuter,TInner,TKey,TResult>(IQueryable<TOuter>, IEnumerable<TInner>, Expression<Func<TOuter,TKey>>, Expression<Func<TInner,TKey>>, Expression<Func<TOuter,TInner,TResult>>) depends on the implementation of the type of the outer parameter.

The expected behavior is that of a left outer join.

The outerKeySelector and innerKeySelector functions are used to extract keys from outer and inner, respectively.

These keys are compared for equality to match elements from each sequence.

A pair of elements is stored for each element in inner that matches an element in outer, plus a pair for each element in outer that has no matches in inner.

Then the resultSelector function is invoked to project a result object from each pair of elements.

Applies to