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
| Rule | Error Code |
|---|---|
| Must have at least one field | GroupByMustHaveFields |
| Fields must be unique (case-insensitive) | GroupByFieldsMustBeUnique |
| Fields cannot be complex/navigation types — a collection of entities fails here too | GroupByFieldCannotBeComplexType |
| Fields cannot be a collection of collections | GroupByFieldCannotBeCollectionType |
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 counts | FieldPath[{path}]StartsWithReservedName |
| Aggregation alias must be a plain identifier — a leading letter (any script) or underscore, then letters, digits, or underscores | InvalidAlias |
| Aggregation aliases must be unique | AggregationAliasesMustBeUnique |
| Aggregation alias cannot match a GroupBy field | AggregationAliasCannotBeGroupByField({alias}) |
| Aggregation field must be a simple type — a collection of entities fails here too | AggregationFieldMustBeSimpleType |
| Aggregation field cannot be a collection of collections | AggregationFieldCannotBeCollectionType |
Sumation / Average only work on numeric fields | UnsupportedAggregatorForType({agg},{type}) |
Minimum / Maximum do not work on Boolean | UnsupportedAggregatorForType({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.