Access via property paths
A property path is a generic way of accessing properties, which are not directly defined as member in the type definition for the instances managed by the property handle.
A property path may refer to a reference or relationship property at the end (last path element), but also at the beginning or in the middle of the path definition. In contrast to a path property, however, the property path does not contain navigation or selection elements, i.e. it contains property names, only, separated by dots (.).
Usually, property paths do apply on properties, only, which are part of the data type managed by the property handle.
Typical example is the address defined as a member of person, which is a structured attribute. The two examples below illustrate the difference between using property references and property paths and make clear, that a property path is just an abbreviation for a list of property references.
Property paths do not need to be executed. The result is represented by the last property referenced in the property path.
// access to city via property references
Property persons(obh, "Person::Persons", PI_Read);
Property address(&persons, "address");
Property city(&address, "city");
// property path to city
Property persons(obh, "Persons", PI_Read);
Property city(&persons, "address.city");
// osi examples
... Person::Test()
{
::message(address.city); // property path
address.{ ::message(city); }; // property references
}
A property path containing reference or relationship properties in at least one path element, which is not the last one, the path can be switched by the expression or application.
In the example below, the property path children.age returns a different value for each iteration depending on the person selected in the children collection.
bool Person::HasGrownupChildren()
{
children.ToTop;
while ( children.Next )
if ( children.age >= 18 ) // age changes for each selected child
return(true);
return(false);
}
When a property path does not start with an extent node or global variable, the path value depends on the instance selected in the parent property. Thus, in the example below, the city name will change for each person selected in the person collection.
collection void Person::Streets()
{
ToTop;
while ( Next )
::Message(name + ": " + address.city);
}