MoreEnumerableOrderedMergeTFirst, TSecond, TKey, TResult Method (IEnumerableTFirst, IEnumerableTSecond, FuncTFirst, TKey, FuncTSecond, TKey, FuncTFirst, TResult, FuncTSecond, TResult, FuncTFirst, TSecond, TResult, IComparerTKey) |
Merges two heterogeneous sequences ordered by a common key type
into a homogeneous one. Additional parameters specify the
element key by which the sequences are ordered, the result when
element is found in first sequence but not in the second,
the result when element is found in second sequence but not in
the first, the result when elements are found in both sequences
and a method for comparing keys.
Namespace:
MoreLinq
Assembly:
MoreLinq (in MoreLinq.dll) Version: 2.1.0
Syntax public static IEnumerable<TResult> OrderedMerge<TFirst, TSecond, TKey, TResult>(
this IEnumerable<TFirst> first,
IEnumerable<TSecond> second,
Func<TFirst, TKey> firstKeySelector,
Func<TSecond, TKey> secondKeySelector,
Func<TFirst, TResult> firstSelector,
Func<TSecond, TResult> secondSelector,
Func<TFirst, TSecond, TResult> bothSelector,
IComparer<TKey> comparer
)
<ExtensionAttribute>
Public Shared Function OrderedMerge(Of TFirst, TSecond, TKey, TResult) (
first As IEnumerable(Of TFirst),
second As IEnumerable(Of TSecond),
firstKeySelector As Func(Of TFirst, TKey),
secondKeySelector As Func(Of TSecond, TKey),
firstSelector As Func(Of TFirst, TResult),
secondSelector As Func(Of TSecond, TResult),
bothSelector As Func(Of TFirst, TSecond, TResult),
comparer As IComparer(Of TKey)
) As IEnumerable(Of TResult)
public:
[ExtensionAttribute]
generic<typename TFirst, typename TSecond, typename TKey, typename TResult>
static IEnumerable<TResult>^ OrderedMerge(
IEnumerable<TFirst>^ first,
IEnumerable<TSecond>^ second,
Func<TFirst, TKey>^ firstKeySelector,
Func<TSecond, TKey>^ secondKeySelector,
Func<TFirst, TResult>^ firstSelector,
Func<TSecond, TResult>^ secondSelector,
Func<TFirst, TSecond, TResult>^ bothSelector,
IComparer<TKey>^ comparer
)
[<ExtensionAttribute>]
static member OrderedMerge :
first : IEnumerable<'TFirst> *
second : IEnumerable<'TSecond> *
firstKeySelector : Func<'TFirst, 'TKey> *
secondKeySelector : Func<'TSecond, 'TKey> *
firstSelector : Func<'TFirst, 'TResult> *
secondSelector : Func<'TSecond, 'TResult> *
bothSelector : Func<'TFirst, 'TSecond, 'TResult> *
comparer : IComparer<'TKey> -> IEnumerable<'TResult>
Parameters
- first
- Type: System.Collections.GenericIEnumerableTFirst
The first input sequence. - second
- Type: System.Collections.GenericIEnumerableTSecond
The second input sequence. - firstKeySelector
- Type: SystemFuncTFirst, TKey
Function to extract a key given an
element from the first sequence. - secondKeySelector
- Type: SystemFuncTSecond, TKey
Function to extract a key given an
element from the second sequence. - firstSelector
- Type: SystemFuncTFirst, TResult
Function to project the result element
when only the first sequence yields a source element. - secondSelector
- Type: SystemFuncTSecond, TResult
Function to project the result element
when only the second sequence yields a source element. - bothSelector
- Type: SystemFuncTFirst, TSecond, TResult
Function to project the result element
when only both sequences yield a source element whose keys are
equal. - comparer
- Type: System.Collections.GenericIComparerTKey
An IComparerT to compare keys.
Type Parameters
- TFirst
- Type of elements in the first sequence.
- TSecond
- Type of elements in the second sequence.
- TKey
- Type of keys used for merging.
- TResult
- Type of elements in the returned sequence.
Return Value
Type:
IEnumerableTResult
A sequence with projections from the two input sequences merged
according to a key, as in a full outer join.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerableTFirst. 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).
Remarks
This method uses deferred execution. The behavior is undefined
if the sequences are unordered (by key) as inputs.
See Also