ParallelEnumerable.GroupBy 方法

定义

根据键选择器函数对序列中的元素进行并行分组。Groups in parallel the elements of a sequence according to a key selector function.

重载

GroupBy<TSource,TKey,TElement,TResult>(ParallelQuery<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, Func<TKey,IEnumerable<TElement>,TResult>, IEqualityComparer<TKey>)

根据指定的键选择器函数对序列中的元素进行分组,并且从每个组及其键中创建结果值。Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. 通过使用指定的比较器对键值进行比较,并且通过使用指定的函数对每个组的元素进行投影。Key values are compared by using a specified comparer, and the elements of each group are projected by using a specified function.

GroupBy<TSource,TKey,TElement,TResult>(ParallelQuery<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, Func<TKey,IEnumerable<TElement>,TResult>)

根据指定的键选择器函数对序列中的元素进行并行分组,并且从每个组及其键中创建结果值。Groups in parallel the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. 通过使用指定的函数对每个组的元素进行投影。The elements of each group are projected by using a specified function.

GroupBy<TSource,TKey,TElement>(ParallelQuery<TSource>, Func<TSource,TKey>, Func<TSource,TElement>)

根据指定的键选择器函数对序列中的元素进行并行分组,并且通过使用指定的函数对每个组中的元素进行投影。Groups in parallel the elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function.

GroupBy<TSource,TKey,TElement>(ParallelQuery<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>)

根据键选择器函数对序列中的元素进行并行分组。Groups in parallel the elements of a sequence according to a key selector function. 通过使用比较器对键进行比较,并且通过使用指定的函数对每个组的元素进行投影。The keys are compared by using a comparer and each group's elements are projected by using a specified function.

GroupBy<TSource,TKey,TResult>(ParallelQuery<TSource>, Func<TSource,TKey>, Func<TKey,IEnumerable<TSource>,TResult>)

根据指定的键选择器函数对序列中的元素进行并行分组,并且从每个组及其键中创建结果值。Groups in parallel the elements of a sequence according to a specified key selector function and creates a result value from each group and its key.

GroupBy<TSource,TKey,TResult>(ParallelQuery<TSource>, Func<TSource,TKey>, Func<TKey,IEnumerable<TSource>,TResult>, IEqualityComparer<TKey>)

根据指定的键选择器函数对序列中的元素进行并行分组,并且从每个组及其键中创建结果值。Groups in parallel the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. 通过使用指定的比较器对键进行比较。The keys are compared by using a specified comparer.

GroupBy<TSource,TKey>(ParallelQuery<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

根据指定的键选择器函数对序列中的元素进行并行分组,并使用指定的 IComparer<T> 对键进行比较。Groups in parallel the elements of a sequence according to a specified key selector function and compares the keys by using a specified IComparer<T>.

GroupBy<TSource,TKey>(ParallelQuery<TSource>, Func<TSource,TKey>)

根据指定的键选择器函数对序列中的元素进行并行分组。Groups in parallel the elements of a sequence according to a specified key selector function.

GroupBy<TSource,TKey,TElement,TResult>(ParallelQuery<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, Func<TKey,IEnumerable<TElement>,TResult>, IEqualityComparer<TKey>)

根据指定的键选择器函数对序列中的元素进行分组,并且从每个组及其键中创建结果值。Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. 通过使用指定的比较器对键值进行比较,并且通过使用指定的函数对每个组的元素进行投影。Key values are compared by using a specified comparer, and the elements of each group are projected by using a specified function.

public:
generic <typename TSource, typename TKey, typename TElement, typename TResult>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::ParallelQuery<TResult> ^ GroupBy(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, TKey> ^ keySelector, Func<TSource, TElement> ^ elementSelector, Func<TKey, System::Collections::Generic::IEnumerable<TElement> ^, TResult> ^ resultSelector, System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public static System.Linq.ParallelQuery<TResult> GroupBy<TSource,TKey,TElement,TResult> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,TKey> keySelector, Func<TSource,TElement> elementSelector, Func<TKey,System.Collections.Generic.IEnumerable<TElement>,TResult> resultSelector, System.Collections.Generic.IEqualityComparer<TKey> comparer);
static member GroupBy : System.Linq.ParallelQuery<'Source> * Func<'Source, 'Key> * Func<'Source, 'Element> * Func<'Key, seq<'Element>, 'Result> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Linq.ParallelQuery<'Result>
<Extension()>
Public Function GroupBy(Of TSource, TKey, TElement, TResult) (source As ParallelQuery(Of TSource), keySelector As Func(Of TSource, TKey), elementSelector As Func(Of TSource, TElement), resultSelector As Func(Of TKey, IEnumerable(Of TElement), TResult), comparer As IEqualityComparer(Of TKey)) As ParallelQuery(Of TResult)

类型参数

TSource

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

TKey

keySelector 返回的键的类型。The type of the key returned by keySelector.

TElement

每个 IGrouping{TKey, TElement} 中的元素的类型。The type of the elements in each IGrouping{TKey, TElement}.

TResult

resultSelector 返回的结果值的类型。The type of the result value returned by resultSelector.

参数

source
ParallelQuery<TSource>

要对其元素进行分组的序列。A sequence whose elements to group.

keySelector
Func<TSource,TKey>

用于提取每个元素的键的函数。A function to extract the key for each element.

elementSelector
Func<TSource,TElement>

用于将每个源元素映射到 IGrouping{Key, TElement} 中的元素的函数。A function to map each source element to an element in an IGrouping{Key, TElement}.

resultSelector
Func<TKey,IEnumerable<TElement>,TResult>

用于从每个组中创建结果值的函数。A function to create a result value from each group.

comparer
IEqualityComparer<TKey>

用于比较键的 IEqualityComparer<T>An IEqualityComparer<T> to compare keys.

返回

ParallelQuery<TResult>

TResult 类型的元素的序列,其中每个元素都表示对一个组及其键的投影。A sequence of elements of type TResult where each element represents a projection over a group and its key.

异常

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

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

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

另请参阅

GroupBy<TSource,TKey,TElement,TResult>(ParallelQuery<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, Func<TKey,IEnumerable<TElement>,TResult>)

根据指定的键选择器函数对序列中的元素进行并行分组,并且从每个组及其键中创建结果值。Groups in parallel the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. 通过使用指定的函数对每个组的元素进行投影。The elements of each group are projected by using a specified function.

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

类型参数

TSource

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

TKey

keySelector 返回的键的类型。The type of the key returned by keySelector.

TElement

每个 IGrouping{TKey, TElement} 中的元素的类型。The type of the elements in each IGrouping{TKey, TElement}.

TResult

resultSelector 返回的结果值的类型。The type of the result value returned by resultSelector.

参数

source
ParallelQuery<TSource>

要对其元素进行分组的序列。A sequence whose elements to group.

keySelector
Func<TSource,TKey>

用于提取每个元素的键的函数。A function to extract the key for each element.

elementSelector
Func<TSource,TElement>

用于将每个源元素映射到 IGrouping<TKey, TElement> 中的元素的函数。A function to map each source element to an element in an IGrouping<TKey, TElement>.

resultSelector
Func<TKey,IEnumerable<TElement>,TResult>

用于从每个组中创建结果值的函数。A function to create a result value from each group.

返回

ParallelQuery<TResult>

TResult 类型的元素的序列,其中每个元素都表示对一个组及其键的投影。A sequence of elements of type TResult where each element represents a projection over a group and its key.

异常

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

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

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

另请参阅

GroupBy<TSource,TKey,TElement>(ParallelQuery<TSource>, Func<TSource,TKey>, Func<TSource,TElement>)

根据指定的键选择器函数对序列中的元素进行并行分组,并且通过使用指定的函数对每个组中的元素进行投影。Groups in parallel the elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function.

public:
generic <typename TSource, typename TKey, typename TElement>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::ParallelQuery<System::Linq::IGrouping<TKey, TElement> ^> ^ GroupBy(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, TKey> ^ keySelector, Func<TSource, TElement> ^ elementSelector);
public static System.Linq.ParallelQuery<System.Linq.IGrouping<TKey,TElement>> GroupBy<TSource,TKey,TElement> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,TKey> keySelector, Func<TSource,TElement> elementSelector);
static member GroupBy : System.Linq.ParallelQuery<'Source> * Func<'Source, 'Key> * Func<'Source, 'Element> -> System.Linq.ParallelQuery<System.Linq.IGrouping<'Key, 'Element>>
<Extension()>
Public Function GroupBy(Of TSource, TKey, TElement) (source As ParallelQuery(Of TSource), keySelector As Func(Of TSource, TKey), elementSelector As Func(Of TSource, TElement)) As ParallelQuery(Of IGrouping(Of TKey, TElement))

类型参数

TSource

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

TKey

keySelector 返回的键的类型。The type of the key returned by keySelector.

TElement

IGrouping<TKey,TElement> 中元素的类型。The type of the elements in the IGrouping<TKey,TElement>.

参数

source
ParallelQuery<TSource>

一个包含要排序的元素的 OrderedParallelQuery<TSource>An OrderedParallelQuery<TSource> that contains elements to sort.

keySelector
Func<TSource,TKey>

用于从元素中提取键的函数。A function to extract a key from an element.

elementSelector
Func<TSource,TElement>

用于将每个源元素映射到 IGrouping<TKey,TElement> 中的元素的函数。A function to map each source element to an element in an IGrouping<TKey,TElement>.

返回

ParallelQuery<IGrouping<TKey,TElement>>

依照 TKey 按降序排列的组序列。A sequence of groups that are sorted descending according to TKey.

异常

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

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

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

另请参阅

GroupBy<TSource,TKey,TElement>(ParallelQuery<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>)

根据键选择器函数对序列中的元素进行并行分组。Groups in parallel the elements of a sequence according to a key selector function. 通过使用比较器对键进行比较,并且通过使用指定的函数对每个组的元素进行投影。The keys are compared by using a comparer and each group's elements are projected by using a specified function.

public:
generic <typename TSource, typename TKey, typename TElement>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::ParallelQuery<System::Linq::IGrouping<TKey, TElement> ^> ^ GroupBy(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, TKey> ^ keySelector, Func<TSource, TElement> ^ elementSelector, System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public static System.Linq.ParallelQuery<System.Linq.IGrouping<TKey,TElement>> GroupBy<TSource,TKey,TElement> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,TKey> keySelector, Func<TSource,TElement> elementSelector, System.Collections.Generic.IEqualityComparer<TKey> comparer);
static member GroupBy : System.Linq.ParallelQuery<'Source> * Func<'Source, 'Key> * Func<'Source, 'Element> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Linq.ParallelQuery<System.Linq.IGrouping<'Key, 'Element>>
<Extension()>
Public Function GroupBy(Of TSource, TKey, TElement) (source As ParallelQuery(Of TSource), keySelector As Func(Of TSource, TKey), elementSelector As Func(Of TSource, TElement), comparer As IEqualityComparer(Of TKey)) As ParallelQuery(Of IGrouping(Of TKey, TElement))

类型参数

TSource

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

TKey

keySelector 返回的键的类型。The type of the key returned by keySelector.

TElement

IGrouping 中的元素的类型The type of the elements in the IGrouping

参数

source
ParallelQuery<TSource>

一个 OrderedParallelQuery{TSource},包含要排序的元素。An OrderedParallelQuery{TSource}that contains elements to sort.

keySelector
Func<TSource,TKey>

用于从元素中提取键的函数。A function to extract a key from an element.

elementSelector
Func<TSource,TElement>

用于将每个源元素映射到 IGrouping 中的元素的函数。A function to map each source element to an element in an IGrouping.

comparer
IEqualityComparer<TKey>

一个用于比较键的 IComparer{TSource}。An IComparer{TSource} to compare keys.

返回

ParallelQuery<IGrouping<TKey,TElement>>

依照 TKey 按降序排列的组序列。A sequence of groups that are sorted descending according to TKey.

异常

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

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

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

另请参阅

GroupBy<TSource,TKey,TResult>(ParallelQuery<TSource>, Func<TSource,TKey>, Func<TKey,IEnumerable<TSource>,TResult>)

根据指定的键选择器函数对序列中的元素进行并行分组,并且从每个组及其键中创建结果值。Groups in parallel the elements of a sequence according to a specified key selector function and creates a result value from each group and its key.

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

类型参数

TSource

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

TKey

keySelector 返回的键的类型。The type of the key returned by keySelector.

TResult

resultSelector 返回的结果值的类型。The type of the result value returned by resultSelector.

参数

source
ParallelQuery<TSource>

要对其元素进行分组的序列。A sequence whose elements to group.

keySelector
Func<TSource,TKey>

用于提取每个元素的键的函数。A function to extract the key for each element.

resultSelector
Func<TKey,IEnumerable<TSource>,TResult>

用于从每个组中创建结果值的函数。A function to create a result value from each group.

返回

ParallelQuery<TResult>

TResult 类型的元素的序列,其中每个元素都表示对一个组及其键的投影。A sequence of elements of type TResult where each element represents a projection over a group and its key.

异常

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

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

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

另请参阅

GroupBy<TSource,TKey,TResult>(ParallelQuery<TSource>, Func<TSource,TKey>, Func<TKey,IEnumerable<TSource>,TResult>, IEqualityComparer<TKey>)

根据指定的键选择器函数对序列中的元素进行并行分组,并且从每个组及其键中创建结果值。Groups in parallel the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. 通过使用指定的比较器对键进行比较。The keys are compared by using a specified comparer.

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

类型参数

TSource

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

TKey

keySelector 返回的键的类型。The type of the key returned by keySelector.

TResult

resultSelector 返回的结果值的类型。The type of the result value returned by resultSelector.

参数

source
ParallelQuery<TSource>

要对其元素进行分组的序列。A sequence whose elements to group.

keySelector
Func<TSource,TKey>

用于提取每个元素的键的函数。A function to extract the key for each element.

resultSelector
Func<TKey,IEnumerable<TSource>,TResult>

用于从每个组中创建结果值的函数。A function to create a result value from each group.

comparer
IEqualityComparer<TKey>

用于比较键的 IEqualityComparer<T>An IEqualityComparer<T> to compare keys.

返回

ParallelQuery<TResult>

一个组序列。A sequence of groups.

异常

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

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

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

另请参阅

GroupBy<TSource,TKey>(ParallelQuery<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

根据指定的键选择器函数对序列中的元素进行并行分组,并使用指定的 IComparer<T> 对键进行比较。Groups in parallel the elements of a sequence according to a specified key selector function and compares the keys by using a specified IComparer<T>.

public:
generic <typename TSource, typename TKey>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::ParallelQuery<System::Linq::IGrouping<TKey, TSource> ^> ^ GroupBy(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, TKey> ^ keySelector, System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public static System.Linq.ParallelQuery<System.Linq.IGrouping<TKey,TSource>> GroupBy<TSource,TKey> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,TKey> keySelector, System.Collections.Generic.IEqualityComparer<TKey> comparer);
static member GroupBy : System.Linq.ParallelQuery<'Source> * Func<'Source, 'Key> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Linq.ParallelQuery<System.Linq.IGrouping<'Key, 'Source>>
<Extension()>
Public Function GroupBy(Of TSource, TKey) (source As ParallelQuery(Of TSource), keySelector As Func(Of TSource, TKey), comparer As IEqualityComparer(Of TKey)) As ParallelQuery(Of IGrouping(Of TKey, TSource))

类型参数

TSource

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

TKey

keySelector>返回的键的类型。The type of the key returned by keySelector>.

参数

source
ParallelQuery<TSource>

一个包含要排序的元素的 OrderedParallelQuery<TSource>An OrderedParallelQuery<TSource> that contains elements to sort.

keySelector
Func<TSource,TKey>

用于从元素中提取键的函数。A function to extract a key from an element.

comparer
IEqualityComparer<TKey>

用于比较键的 IComparer<T>An IComparer<T> to compare keys.

返回

ParallelQuery<IGrouping<TKey,TSource>>

依照 TKey 按降序排列的组序列。A sequence of groups that are sorted descending according to TKey.

异常

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

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

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

另请参阅

GroupBy<TSource,TKey>(ParallelQuery<TSource>, Func<TSource,TKey>)

根据指定的键选择器函数对序列中的元素进行并行分组。Groups in parallel the elements of a sequence according to a specified key selector function.

public:
generic <typename TSource, typename TKey>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::ParallelQuery<System::Linq::IGrouping<TKey, TSource> ^> ^ GroupBy(System::Linq::ParallelQuery<TSource> ^ source, Func<TSource, TKey> ^ keySelector);
public static System.Linq.ParallelQuery<System.Linq.IGrouping<TKey,TSource>> GroupBy<TSource,TKey> (this System.Linq.ParallelQuery<TSource> source, Func<TSource,TKey> keySelector);
static member GroupBy : System.Linq.ParallelQuery<'Source> * Func<'Source, 'Key> -> System.Linq.ParallelQuery<System.Linq.IGrouping<'Key, 'Source>>
<Extension()>
Public Function GroupBy(Of TSource, TKey) (source As ParallelQuery(Of TSource), keySelector As Func(Of TSource, TKey)) As ParallelQuery(Of IGrouping(Of TKey, TSource))

类型参数

TSource

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

TKey

keySelector 返回的键的类型。The type of the key returned by keySelector.

参数

source
ParallelQuery<TSource>

一个 OrderedParallelQuery{TSource},包含要排序的元素。An OrderedParallelQuery{TSource}that contains elements to sort.

keySelector
Func<TSource,TKey>

用于从元素中提取键的函数。A function to extract a key from an element.

返回

ParallelQuery<IGrouping<TKey,TSource>>

依照 TKey 按降序排列的组序列。A sequence of groups that are sorted descending according to TKey.

异常

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

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

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

另请参阅

适用于