Type: VirtualColl
The read-only instances property of the Class class contains a reference to persistent instances of the class that it represents. (See also "Caveat When Handling Persistent Class Instances", earlier in this section.) This property enables you to access persistent class instances as though they were in a class collection without having to populate a collection; for example:
vars product : Product; begin foreach product in Product.instances do product.printDetails; endforeach; end;
The order in which instances are returned when iterating a virtual collection is not significant.
The following examples show how the instances property, which is a virtual collection, can be used with normal collection methods.
count := Employee.instances.size; // count instances
Employee.instances.purge; // delete all instances
emp := Employee.instances.first.Employee; // first instance
cust := Customer.instances.last.Customer; // last instance
Product.instances.copy(tempColl); // copy to temporary collection