MoreEnumerableOrderedMergeTFirst, TSecond, TKey, TResult Method (IEnumerableTFirst, IEnumerableTSecond, FuncTFirst, TKey, FuncTSecond, TKey, FuncTFirst, TResult, FuncTSecond, TResult, FuncTFirst, TSecond, TResult) |
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 and
the result when element is found in second sequence but not in
the first, the result when elements are found in both sequences.
Namespace:
MoreLinq
Assembly:
MoreLinq (in MoreLinq.dll) Version: 3.0.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
)
<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)
) 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
)
[<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> -> 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.
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