[ROOT] / doc / toc / ARCQuery / Class / CompoundKey

FunctionKeys , Parse , QuantileKey , ToString , TryGetP , TryGetPInternal


A class able to expand the concept of entity keys.

Example: In addition to ordinary keys for 'Customer' like 'FirstName', 'LastName' and 'DateOfBirth', it is able to offer:
1) Expressions like "FirstName'+' '+'LastName" (see BinaryOperatorKey and ConstantKey<T>).
2) Keys implemented directly in actual class like 'Name' (see EntityMethodKey).
3) Functions acting on keys, like 'DateOfBirth.Year()' (see FunctionKey / FunctionKeyYear).
4) Global new keys like 'CountP()' (see NewKey / NewKeyCountP).
5) Foreign keys with for instance aggregations like 'Order.Amount.Sum()' (see ForeignKey / FunctionKeyAggregate / -FunctionKeyAggregateSum).

These keys / expressions can then be used whenever ordinary keys are used, like in QueryExpressions like SELECT, WHERE, AGGREGATE, PIVOT and so on.

Most relevant sub classes of CompoundKey are:

1) BinaryOperatorKey: Offers expressions with operators like +, -, * and /.

2) ConstantKey<T>: Represents a constant expression like "' '", "', '", "42".

3) EntityMethodKey: Key able to call read-only methods defined in the entity class with names like 'TryGet{FieldName}'.
Example: For 'Customer' it can find 'Customer.Name' which is calculated in a read-only method Customer.TryGetName as combination of 'FirstName', 'LastName' and 'CompanyName'.

4) NewKey: Creates new keys available for all entities.
Example: For 'Customer' it can count number of properties through 'CountP' (see NewKeyCountP.)

5) ForeignKey: Can find related values.
Example: For 'Order', it can find 'Customer.Name'.

6) MemberEntityKey: Can find value for entity which is member of entity being queried.
Example: For 'Order', it can find 'Customer.Name'.

Closely related classes (Stored inside CompoundKey as members FunctionKeys, and QuantileKey) are:
1) FunctionKey / FunctionKeyAggregate: Extracts data from an already existing value like 'Created.Year()' (see FunctionKeyYear)
and
2) QuantileKey: Can separate entities into quantiles, like Quartiles, Quintiles or Sextiles

(See also ValueComparer which can evaluation expressions like for 'Customer': 'WHERE Created = ThisYear')

Other sub-classes of CompoundKey are OrdinaryKeyPlusFunctionOrQuantile and CompoundInvalidKey.

See common parser for all compound keys (Parse) which will always 'succeed' (a 'TryParse'-method is neither needed nor offered, CompoundInvalidKey is returned if not key found).

Note how compound keys (and related keys) may be chained several levels deep, like for 'Order': 'Customer.Created.Year()' or for 'Customer': 'Order.Amount.Sum()' or even 'Order.Amount.Sum().QUARTILE'.
This is all parsed in Parse and stored in FunctionKeys / QuantileKey.

See QueryExpressionSelect for hint about using 'AS'-clause in order to simplify parsing and evaluation in subsequent QueryExpressions when using CompoundKey.

All keys can be followed by one or several FunctionKeys

A QuantileKey can only be the last key in a chain, like 'Customer.Order.Amount.Sum().QUARTILE'.
It is not evaluated by CompoundKey.TryGetP, it is instead evaluated by ARCQuery. Extensions.TryGetP)


FunctionKeysAll FunctionKeys chained at end of compound key (but before an eventual QuantileKey).
ParseNote that no TryParse is offered here, because Parse will always succeed (it just returns CompoundInvalidKey if 'fails').
QuantileKeyEventual final QuantileKey at end of compound key.
ToStringThe ToString representation is the one relevant when used as key, like in IK or when selecting like 'SELECT {fieldName}'.
TryGetPThe outwards facing executor, understanding use of FunctionKeys.
TryGetPInternalThe internal executor, containing the specific functionality for how to evaluate the key.

Details

Generated 2024-04-18 23:49:36.210 UTC