HpcLinqQueryable.AggregateAsQuery Method (IQueryable, TAccumulate, Expression)

Creates a query that you can run later to combine a set of records by using the specified function, and by using the specified seed value as the initial accumulator value.


Namespace: Microsoft.Hpc.Linq
Assembly: Microsoft.Hpc.Linq (in Microsoft.Hpc.Linq.dll)

'Usage
Dim source As IQueryable(Of TSource)
Dim seed As TAccumulate
Dim func As Expression(Of Func(Of TAccumulate, TSource, TAccumulate))
Dim returnValue As IQueryable(Of TAccumulate)

returnValue = HpcLinqQueryable.AggregateAsQuery(source, seed, func)

[ExtensionAttribute] 
public static IQueryable<TAccumulate> AggregateAsQuery<TSource,TAccumulate> (
	IQueryable<TSource> source,
	TAccumulate seed,
	Expression<Func<TAccumulate,TSource,TAccumulate>> func
)
J# supports the use of generic APIs, but not the declaration of new ones.
JScript does not support generic types or methods.

GenericParameters

TSource

The type of the records in the source parameter.

TAccumulate

The type of the accumulator value. This type is the type of the seed parameter and the return type of the function that the func parameter specifies.

Parameters

source

A System.Linq.IQueryable<TSource> interface for the set of records that you want to process.

seed

A value of the type specified by the TAccumalate parameter that specifies the initial seed value to use for the function that combines the records.

func

A System.Linq.Expressions.Expression(Func(TAccumulate, TSource, TAccumulate)) object that specifies a function that combines the records.

The specified function is applied to each record in the set of records and the accumulated value is returned.

The function should be marked with the Associative attribute, so that the computation for the query is distributed across the HPC cluster and does not result in performance problems. For more information about this attribute, see "Using the [Associative] attribute for Distributed Aggregation" in the LINQ to HPC and DSC Programmer's Guide.

Return Value

An IQueryable interface for the query.

Exception typeCondition
ArgumentNullException

The specified source or func parameter is a null reference (Nothing in Visual Basic).

Use this method if you want to perform the same query as the Aggregate method, but want to delay running the query instead of generating results immediately.

Use the Submit method to run the query. Use the GetEnumerator method or the foreach statement of the C# language (For Each in Visual Basic) to get the results of the query. The enumerator contains a single element of the type that the TAccumulate parameter specifies, which is the result of combining all of the records by using the specified function and specified seed value.

To create a query that combines a set of records by using a specified function and by using the first record as the initial accumulator value, use the AggregateAsQuery(Generic IQueryable,Generic Expression) form of the method. To create a query that combines a set of records by using a specified function and by using a specified seed value as the initial accumulator value, and that also uses a second function to transform the accumulated value to a final result, use the AggregateAsQuery(Generic IQueryable,K,Generic Expression,Generic Expression) form of the method.

In Visual Basic and C#, you can call this method as an instance method on any object of type IQueryable<TSource>. 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).

This method has at least one parameter of type Expression with a type argument that is one of the Func types. For these parameters, you can pass in a lambda expression and it compiles to an Expression.

To simplify common aggregation operations, the set of standard query operators also includes the counting methods CountAsQuery and LongCountAsQuery, and numeric aggregation methods, namely MaxAsQuery, MinAsQuery, SumAsQuery, and AverageAsQuery.

For more information about how the query runs and its behavior, see the Remarks section for the Aggregate method.

Platform Note: This method was introduced in Windows HPC Server 2008 R2 with Service Pack 2 (SP2) and is not supported in previous versions.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows XP, Windows Vista, Windows 7, Windows 8, Windows Server 2003, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012

Target Platforms

Windows XP, Windows Vista, Windows 7, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, with HPC Pack Client Utilities




Build Date:

2013-04-22
Show: