DynamicWhere.ex
DynamicWhere.exv3.4.0·docs

GroupBy Validation

A GroupBy shape is heavily validated because both the group keys and the aggregations feed the generated SQL GROUP BY / SELECT clauses.

Rules

RuleError Code
Must have at least one fieldGroupByMustHaveFields
Fields must be unique (case-insensitive)GroupByFieldsMustBeUnique
Fields cannot be complex/navigation types — a collection of entities fails here tooGroupByFieldCannotBeComplexType
Fields cannot be a collection of collectionsGroupByFieldCannotBeCollectionType
A GroupBy field or an AggregateBy.Field cannot start with a name the expression parser keeps for itself — new, iif, np, isnull, is, as, cast, true, false, null, in any letter case. Only the first segment countsFieldPath[{path}]StartsWithReservedName
Aggregation alias must be a plain identifier — a leading letter (any script) or underscore, then letters, digits, or underscoresInvalidAlias
Aggregation aliases must be uniqueAggregationAliasesMustBeUnique
Aggregation alias cannot match a GroupBy fieldAggregationAliasCannotBeGroupByField({alias})
Aggregation field must be a simple type — a collection of entities fails here tooAggregationFieldMustBeSimpleType
Aggregation field cannot be a collection of collectionsAggregationFieldCannotBeCollectionType
Sumation / Average only work on numeric fieldsUnsupportedAggregatorForType({agg},{type})
Minimum / Maximum do not work on BooleanUnsupportedAggregatorForType({agg},{type})
Note
Dotted GroupBy fields like Category.Name are allowed if the leaf is a simple type. Only the leaf is the actual key; the dotted path is flattened into an alias such as CategoryName in the result. See the Summary example.
Warning
A path that ends on a collection is checked against its element type, so a collection of entities is reported as GroupByFieldCannotBeComplexType / AggregationFieldMustBeSimpleType, and a collection of simple values (List<string>) passes validation. The ...CannotBeCollectionType codes are reached only by a collection of collections.