company logo

Special behavior of operation path

In general, a property handle opened for an operation path behaves similar to any other property handle, i.e. it provides the same functionality. Nevertheless, the operation path defines a virtual collection of instances, which is calculated, when accessing the operation path. When accessing instances of a operation path frequently and not in sequence, it is suggested to run the operation path and create a transient or virtual collection for the result.

In contrast to property handles based on property, path properties or property path, the operation path is read only in most cases. Only, when the result returns persistent instances, updates might be possible in some cases. Simple operation paths are paths containing a filter condition (where operation) or an order statement (order operation).

    Persons.OrderBy("sk_name").Where(age > 40)

Even though this operation path reorders persons and selects persons over 40, the result set still refers to the original person collection and persistent person instances. Other operations as Intersect or From (Join) also allow updates, because tracing back to the origin is still possible. Partially, this is also true for the select statement, as long as the property assignments in the select statement refer to property paths or path properties, only.

This sounds rather difficult, but practically, you can update operation path properties, as long as you understand, what you are updating at the origin (this simple rule is not 100% true, but it helps). When a property in an operation path has lost its origin, the property handle will reject any modification attempt.

What usually not works in a virtual collection is locating instances by key. Other virtual collections can be access forward, only. Hence, one has to check in the specific situation, what type of operation is supported by the operation path creating the virtual collection.

Operation paths are good for getting ad hoc answers or processing query results sequentially (forward). When more flexible access is required for accessing the result, it is better to create transient or temporary collections from the access path storing the selection.

  char           *query = "Person::Persons.Select(                        \

                   pid, address,                                  \

                   STRING full_name = {                           \

                       VARIABLES                                  \

                         bool                 first = true;       \

                         STRING               result = 'Mrs. ';   \

                         SET<MessageEingang> &mi = message(0).an; \

                       PROCESS                                    \

                         if ( sex == 'male' )                     \

                           result = 'Mr. ';                       \

                         result << first_name << ' ' << name;     \

                        return(result);                           \

                  }";

  Property  ph(dbo,query,PI_Read);