If you have a comment on this topic, contact Aptify Documentation. If you want to return to the Aptify Community Site, please click here.

About the Optional Embedded Objects

There are cases when a foreign key relationship is established as an optional relationship between records. For example, a company may or may not have a Billing Address that is different from its primary address. In those types of scenarios, an embedded object may or may not exist for a given foreign key in the Generic Entity (GE) object model.

The GE object model optimizes the loading of embedded objects when a containing object is first loaded. For example, if a Company GE object is loaded up, only the Company GE object itself is loaded into memory initially. The virtual fields associated with the CompanyGE are available for read-access without needing to access the embedded GE object since those values are carried in the Company GE itself as virtual fields.

The embedded GE is loaded up only if a change is being made to an embedded object, or if a user's code directly requests the underlying embedded object through the Dot syntax method or direct embedded object access. This approach is completely transparent to developers that are using the GE but is important to be aware of since it improves performance of the GE object loading and saving by a considerable margin.

To determine whether an embedded object has been loaded by the GE, check the AptifyDataFieldBase.EmbeddedObjectExists function. This function is used by the parent GE object to determine whether or not the Embedded GE object has been loaded. It returns True if the Embedded object has been instantiated and False otherwise. See the Aptify Software Development Kit (SDK) for more information.

The EmbeddedObjectExists function provides a valuable service since the Embedded GE object will only be loaded when it is required. If the parent GE identifies that the Embedded record has not been loaded, which means it has not been changed, no further interaction is required, and the parent GE can optimize its Validation and Save operations. Conversely, if you access the AptifyDataFieldBase.EmbeddedObject method, the system will load the Embedded GE object each time, even when it is not necessary.

Copyright © 2014-2017 Aptify - Confidential and Proprietary