Export (0) Print
Expand All
Expand Minimize

DbExpressionBuilder.GroupBy Method

.NET Framework 4.5

Creates a new DbGroupByExpression that groups the elements of the input set according to the specified group keys and applies the given aggregates.

Namespace:  System.Data.Common.CommandTrees.ExpressionBuilder
Assembly:  System.Data.Entity (in System.Data.Entity.dll)

public static DbGroupByExpression GroupBy(
	this DbGroupExpressionBinding input,
	IEnumerable<KeyValuePair<string, DbExpression>> keys,
	IEnumerable<KeyValuePair<string, DbAggregate>> aggregates


Type: System.Data.Common.CommandTrees.DbGroupExpressionBinding

A DbGroupExpressionBinding that specifies the input set.

Type: System.Collections.Generic.IEnumerable<KeyValuePair<String, DbExpression>>

A list of string-expression pairs that define the grouping columns.

Type: System.Collections.Generic.IEnumerable<KeyValuePair<String, DbAggregate>>

A list of expressions that specify aggregates to apply.

Return Value

Type: System.Data.Common.CommandTrees.DbGroupByExpression
A new DbGroupByExpression with the specified input set, grouping keys and aggregates.

Usage Note

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


input, keys or aggregates is null, keys contains a null column key or expression, or aggregates contains a null aggregate column name or aggregate.


Both keys and aggregates are empty, or an invalid or duplicate column name was specified.

DbGroupByExpression allows either the list of keys or the list of aggregates to be empty, but not both.

.NET Framework

Supported in: 4.5

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft