AggregateOperand.Max(CriteriaOperator) Method
Creates a new AggregateOperand which returns the maximum of the values calculated by the given aggregate expression. This expression is evaluated against elements of the AggregateOperand.CollectionProperty that match the specified AggregateOperand.Condition.
Namespace: DevExpress.Data.Filtering
Assembly: DevExpress.Data.v24.2.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
aggregatedExpression | CriteriaOperator | A CriteriaOperator object which specifies the aggregate expression. This parameter may be ignored in certain circumstances. |
Returns
Type | Description |
---|---|
AggregateOperand | An AggregateOperand object which calculates an aggregate expression. |
Example
Example 1
Get the max value from a whole collection.
Expression:
CriteriaOperator.FromLambda<Order, int>(o => o.OrderItems.Max(oi => oi.ItemPrice));
Input:
Order | OrderItemName | ItemPrice |
---|---|---|
Order0 | ||
OrderItem1 | 10 | |
OrderItem2 | 20 |
The result: 20
Example 2
Get the max value from a filtered collection.
Expression:
CriteriaOperator.FromLambda<Order, int>(o => o.OrderItems.Where(oi => oi.IsAvailable == true).Max(oi => oi.ItemPrice)); ;
Input:
Order | OrderItemName | ItemPrice | IsAvailable |
---|---|---|---|
Order0 | |||
OrderItem1 | 10 | False | |
OrderItem2 | 20 | True | |
OrderItem2 | 30 | True | |
OrderItem2 | 40 | False |
The result: 30