ParallelEnumerable.SelectMany 方法

定义

将序列的每个元素以并行方式投影到 IEnumerable<T> 并将结果序列合并为一个序列。Projects in parallel each element of a sequence to an IEnumerable<T> and flattens the resulting sequences into one sequence.

重载

SelectMany<TSource,TCollection,TResult>(ParallelQuery<TSource>, Func<TSource,IEnumerable<TCollection>>, Func<TSource,TCollection,TResult>)

将序列的每个元素投影到 IEnumerable<T>,并将结果序列合并为一个序列,并对其中每个元素调用结果选择器函数。Projects each element of a sequence to an IEnumerable<T>, flattens the resulting sequences into one sequence, and invokes a result selector function on each element therein.

SelectMany<TSource,TCollection,TResult>(ParallelQuery<TSource>, Func<TSource,Int32,IEnumerable<TCollection>>, Func<TSource,TCollection,TResult>)

将序列的每个元素投影到 IEnumerable<T>,并将结果序列合并为一个序列,并对其中每个元素调用结果选择器函数。Projects each element of a sequence to an IEnumerable<T>, flattens the resulting sequences into one sequence, and invokes a result selector function on each element therein. 每个源元素的索引用于该元素的中间投影表。The index of each source element is used in the intermediate projected form of that element.

SelectMany<TSource,TResult>(ParallelQuery<TSource>, Func<TSource,IEnumerable<TResult>>)

将序列的每个元素以并行方式投影到 IEnumerable<T> 并将结果序列合并为一个序列。Projects in parallel each element of a sequence to an IEnumerable<T> and flattens the resulting sequences into one sequence.

SelectMany<TSource,TResult>(ParallelQuery<TSource>, Func<TSource,Int32,IEnumerable<TResult>>)

将序列的每个元素以并行方式投影到 IEnumerable<T> 并将结果序列合并为一个序列。Projects in parallel each element of a sequence to an IEnumerable<T>, and flattens the resulting sequences into one sequence. 每个源元素的索引用于该元素的投影表。The index of each source element is used in the projected form of that element.

SelectMany<TSource,TCollection,TResult>(ParallelQuery<TSource>, Func<TSource,IEnumerable<TCollection>>, Func<TSource,TCollection,TResult>)

将序列的每个元素投影到 IEnumerable<T>,并将结果序列合并为一个序列,并对其中每个元素调用结果选择器函数。Projects each element of a sequence to an IEnumerable<T>, flattens the resulting sequences into one sequence, and invokes a result selector function on each element therein.

public:
generic <typename TSource, typename TCollection, typename TResult>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::ParallelQuery<TResult> ^ SelectMany(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, System::Collections::Generic::IEnumerable<TCollection> ^> ^ collectionSelector, Func<TSource, TCollection, TResult> ^ resultSelector);
public static System.Linq.ParallelQuery<TResult> SelectMany<TSource,TCollection,TResult> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,System.Collections.Generic.IEnumerable<TCollection>> collectionSelector, Func<TSource,TCollection,TResult> resultSelector);
static member SelectMany : System.Linq.ParallelQuery<'Source> * Func<'Source, seq<'Collection>> * Func<'Source, 'Collection, 'Result> -> System.Linq.ParallelQuery<'Result>
<Extension()>
Public Function SelectMany(Of TSource, TCollection, TResult) (source As ParallelQuery(Of TSource), collectionSelector As Func(Of TSource, IEnumerable(Of TCollection)), resultSelector As Func(Of TSource, TCollection, TResult)) As ParallelQuery(Of TResult)

类型参数

TSource

collectionSelector 收集的中间元素的类型。The type of the intermediate elements collected by collectionSelector.

TCollection

source 的元素类型。The type of elements of source.

TResult

结果序列中的元素的类型。The type of elements in the result sequence.

参数

source
ParallelQuery<TSource>

一个要投影的值序列。A sequence of values to project.

collectionSelector
Func<TSource,IEnumerable<TCollection>>

一个应用于每个源元素的转换函数;函数的第二个参数表示源元素的索引。A transform function to apply to each source element; the second parameter of the function represents the index of the source element.

resultSelector
Func<TSource,TCollection,TResult>

用于从第一个序列的元素和第二个序列的匹配元素集合中创建结果元素的函数。A function to create a result element from an element from the first sequence and a collection of matching elements from the second sequence.

返回

ParallelQuery<TResult>

一个序列,其元素是通过以下方法得到的:对基于提供给 collectionSelectorsource 的每个元素调用一对多转换函数 collectionSelector,然后将这些序列元素中的每一个元素及其相应的源元素映射到一个结果元素。A sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of source based on the index supplied to collectionSelector, and then mapping each of those sequence elements and their corresponding source element to a result element.

例外

sourceselector 为 null 引用(在 Visual Basic 中为 Nothing)。source or selector is a null reference (Nothing in Visual Basic).

已使用通过 WithCancellation 传递的令牌取消了查询。The query was canceled with the token passed in through WithCancellation.

该查询枚举的元素超过了 MaxValue 个。More than MaxValue elements are enumerated by the query.

评估查询期间发生一个或多个异常。One or more exceptions occurred during the evaluation of the query.

另请参阅

SelectMany<TSource,TCollection,TResult>(ParallelQuery<TSource>, Func<TSource,Int32,IEnumerable<TCollection>>, Func<TSource,TCollection,TResult>)

将序列的每个元素投影到 IEnumerable<T>,并将结果序列合并为一个序列,并对其中每个元素调用结果选择器函数。Projects each element of a sequence to an IEnumerable<T>, flattens the resulting sequences into one sequence, and invokes a result selector function on each element therein. 每个源元素的索引用于该元素的中间投影表。The index of each source element is used in the intermediate projected form of that element.

public:
generic <typename TSource, typename TCollection, typename TResult>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::ParallelQuery<TResult> ^ SelectMany(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, int, System::Collections::Generic::IEnumerable<TCollection> ^> ^ collectionSelector, Func<TSource, TCollection, TResult> ^ resultSelector);
public static System.Linq.ParallelQuery<TResult> SelectMany<TSource,TCollection,TResult> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,int,System.Collections.Generic.IEnumerable<TCollection>> collectionSelector, Func<TSource,TCollection,TResult> resultSelector);
static member SelectMany : System.Linq.ParallelQuery<'Source> * Func<'Source, int, seq<'Collection>> * Func<'Source, 'Collection, 'Result> -> System.Linq.ParallelQuery<'Result>
<Extension()>
Public Function SelectMany(Of TSource, TCollection, TResult) (source As ParallelQuery(Of TSource), collectionSelector As Func(Of TSource, Integer, IEnumerable(Of TCollection)), resultSelector As Func(Of TSource, TCollection, TResult)) As ParallelQuery(Of TResult)

类型参数

TSource

collectionSelector 收集的中间元素的类型。The type of the intermediate elements collected by collectionSelector.

TCollection

source 的元素类型。The type of elements of source.

TResult

要返回的元素的类型。The type of elements to return.

参数

source
ParallelQuery<TSource>

一个要投影的值序列。A sequence of values to project.

collectionSelector
Func<TSource,Int32,IEnumerable<TCollection>>

一个应用于每个源元素的转换函数;函数的第二个参数表示源元素的索引。A transform function to apply to each source element; the second parameter of the function represents the index of the source element.

resultSelector
Func<TSource,TCollection,TResult>

用于从第一个序列的元素和第二个序列的匹配元素集合中创建结果元素的函数。A function to create a result element from an element from the first sequence and a collection of matching elements from the second sequence.

返回

ParallelQuery<TResult>

一个序列,其元素是通过以下方法得到的:对基于提供给 collectionSelectorsource 的每个元素调用一对多转换函数 collectionSelector,然后将这些序列元素中的每一个元素及其相应的源元素映射到一个结果元素。A sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of source based on the index supplied to collectionSelector, and then mapping each of those sequence elements and their corresponding source element to a result element.

例外

sourceselector 为 null 引用(在 Visual Basic 中为 Nothing)。source or selector is a null reference (Nothing in Visual Basic).

已使用通过 WithCancellation 传递的令牌取消了查询。The query was canceled with the token passed in through WithCancellation.

该查询枚举的元素超过了 MaxValue 个。More than MaxValue elements are enumerated by the query.

评估查询期间发生一个或多个异常。One or more exceptions occurred during the evaluation of the query.

另请参阅

SelectMany<TSource,TResult>(ParallelQuery<TSource>, Func<TSource,IEnumerable<TResult>>)

将序列的每个元素以并行方式投影到 IEnumerable<T> 并将结果序列合并为一个序列。Projects in parallel each element of a sequence to an IEnumerable<T> and flattens the resulting sequences into one sequence.

public:
generic <typename TSource, typename TResult>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::ParallelQuery<TResult> ^ SelectMany(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, System::Collections::Generic::IEnumerable<TResult> ^> ^ selector);
public static System.Linq.ParallelQuery<TResult> SelectMany<TSource,TResult> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,System.Collections.Generic.IEnumerable<TResult>> selector);
static member SelectMany : System.Linq.ParallelQuery<'Source> * Func<'Source, seq<'Result>> -> System.Linq.ParallelQuery<'Result>
<Extension()>
Public Function SelectMany(Of TSource, TResult) (source As ParallelQuery(Of TSource), selector As Func(Of TSource, IEnumerable(Of TResult))) As ParallelQuery(Of TResult)

类型参数

TSource

source 的元素类型。The type of elements of source.

TResult

选择器返回的序列元素的类型。The type of the elements of the sequence returned by selector.

参数

source
ParallelQuery<TSource>

一个要投影的值序列。A sequence of values to project.

selector
Func<TSource,IEnumerable<TResult>>

应用于每个元素的转换函数。A transform function to apply to each element.

返回

ParallelQuery<TResult>

一个序列,其元素是对输入序列的每个元素调用一对多转换函数的结果。A sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.

例外

sourceselector 为 null 引用(在 Visual Basic 中为 Nothing)。source or selector is a null reference (Nothing in Visual Basic).

已使用通过 WithCancellation 传递的令牌取消了查询。The query was canceled with the token passed in through WithCancellation.

评估查询期间发生一个或多个异常。One or more exceptions occurred during the evaluation of the query.

另请参阅

SelectMany<TSource,TResult>(ParallelQuery<TSource>, Func<TSource,Int32,IEnumerable<TResult>>)

将序列的每个元素以并行方式投影到 IEnumerable<T> 并将结果序列合并为一个序列。Projects in parallel each element of a sequence to an IEnumerable<T>, and flattens the resulting sequences into one sequence. 每个源元素的索引用于该元素的投影表。The index of each source element is used in the projected form of that element.

public:
generic <typename TSource, typename TResult>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::ParallelQuery<TResult> ^ SelectMany(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, int, System::Collections::Generic::IEnumerable<TResult> ^> ^ selector);
public static System.Linq.ParallelQuery<TResult> SelectMany<TSource,TResult> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,int,System.Collections.Generic.IEnumerable<TResult>> selector);
static member SelectMany : System.Linq.ParallelQuery<'Source> * Func<'Source, int, seq<'Result>> -> System.Linq.ParallelQuery<'Result>
<Extension()>
Public Function SelectMany(Of TSource, TResult) (source As ParallelQuery(Of TSource), selector As Func(Of TSource, Integer, IEnumerable(Of TResult))) As ParallelQuery(Of TResult)

类型参数

TSource

source 的元素类型。The type of elements of source.

TResult

选择器返回的序列元素的类型。The type of the elements of the sequence returned by selector.

参数

source
ParallelQuery<TSource>

一个要投影的值序列。A sequence of values to project.

selector
Func<TSource,Int32,IEnumerable<TResult>>

应用于每个元素的转换函数。A transform function to apply to each element.

返回

ParallelQuery<TResult>

一个序列,其元素是对输入序列的每个元素调用一对多转换函数的结果。A sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.

例外

sourceselector 为 null 引用(在 Visual Basic 中为 Nothing)。source or selector is a null reference (Nothing in Visual Basic).

已使用通过 WithCancellation 传递的令牌取消了查询。The query was canceled with the token passed in through WithCancellation.

该查询枚举的元素超过了 MaxValue 个。More than MaxValue elements are enumerated by the query.

评估查询期间发生一个或多个异常。One or more exceptions occurred during the evaluation of the query.

另请参阅

适用于