MoreEnumerable.LeftJoin<TFirst, TSecond, TKey, TResult>(IEnumerable<TFirst>, IEnumerable<TSecond>, Func<TFirst, TKey>, Func<TSecond, TKey>, Func<TFirst, TResult>, Func<TFirst, TSecond, TResult>, IEqualityComparer<TKey>) Method

Performs a left outer join on two heterogeneous sequences. Additional arguments specify key selection functions, result projection functions and a key comparer.

Definition

Namespace: MoreLinq
Assembly: MoreLinq (in MoreLinq.dll) Version: 4.1.0+0e154ef592f33ce0f6f3d534a9eedee273f0ce72
C#
public static IEnumerable<TResult> LeftJoin<TFirst, TSecond, TKey, TResult>(
	this IEnumerable<TFirst> first,
	IEnumerable<TSecond> second,
	Func<TFirst, TKey> firstKeySelector,
	Func<TSecond, TKey> secondKeySelector,
	Func<TFirst, TResult> firstSelector,
	Func<TFirst, TSecond, TResult> bothSelector,
	IEqualityComparer<TKey>? comparer
)

Parameters

first  IEnumerable<TFirst>
The first sequence of the join operation.
second  IEnumerable<TSecond>
The second sequence of the join operation.
firstKeySelector  Func<TFirst, TKey>
Function that projects the key given an element from first.
secondKeySelector  Func<TSecond, TKey>
Function that projects the key given an element from second.
firstSelector  Func<TFirst, TResult>
Function that projects the result given just an element from first where there is no corresponding element in second.
bothSelector  Func<TFirst, TSecond, TResult>
Function that projects the result given an element from first and an element from second that match on a common key.
comparer  IEqualityComparer<TKey>
The IEqualityComparer<T> instance used to compare keys for equality.

Type Parameters

TFirst
The type of elements in the first sequence.
TSecond
The type of elements in the second sequence.
TKey
The type of the key returned by the key selector functions.
TResult
The type of the result elements.

Return Value

IEnumerable<TResult>
A sequence containing results projected from a left outer join of the two input sequences.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<TFirst>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also