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

AllEntityMethodKeysForEntityType , FunctionKeys , Method , QuantileKey , ToString , TryGetForeignField , TryGetP , TryGetPInternal

Key able to call read-only methods defined in the entity class with names like 'TryGet{FieldName}'.

Some common usages of this would be to implement:
- In a class called 'Customer' with 'FirstName' and 'LastName', a new property 'Name'.
- In a class called 'OrderLine' with 'Quantity' and 'UnitPrice', a new property 'Sum'.

The principle can also be used to simplify querying while still having tables normalized.
If for instance address data for 'Customer' objects is normalized into a separate table 'Geography' then one could implement properties on 'Customer' like 'City', 'State', 'Country'.
This would enable querying for 'Customer' like
'SELECT Name, Address, City, State, Country'
instead of the more laborous
'SELECT Geography.Name, Geography.Address, Geography.City, Geography.State, Geography.Country'
(see TryGetForeignField which is a helper method for this purpose).

Implementations of a few such properties can often significantly reduce the complexity of queries / reduce the need for denormalizing tables in the database.

The risk of bugs are also reduced since the properties will only be defined in one place, as close as possible to its source propertiesinstead of complex query components being repeated multiple times in a reporting system for instance.

This class (EntityMethodKey) looks for such entity property defining methods through reflection.
It is able to call methods with signatures like either:
bool TryGet{KeyName}(out IP retval, out string errorResponse) (see Simple)
bool TryGet{KeyName}(IP dataStorage, IK thisKey, out IP retval, out string errorResponse) (see Complex)

These should be read-only methods / read-only properties, that is, they should not change the state of the entity or the data storage.

Note: 'out IP retval' can be any type assignable to IP, so it is recommended to use more strongly typing in the method signature, like 'out PValue<DateTime> retval' for instance.

See also NewKey (creating new keys (new fields) for all entity object types).

AllEntityMethodKeysForEntityTypeReturns methods for the given entity type that can be used by EntityMethodKey.
FunctionKeysAll FunctionKeys chained at end of compound key (but before an eventual QuantileKey).
MethodThe actuall TryGet method implemented in the relevant entity class.
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}'.
TryGetForeignFieldReturns foreign field through foreign key given.
TryGetPThe outwards facing executor, understanding use of FunctionKeys.
TryGetPInternalThe internal executor, containing the specific functionality for how to evaluate the key.


Generated 2021-06-19 18:17:45.606 UTC