How to: Initialize Business Objects with Default Property Values

时间:2022-09-25 12:44:55

4种属性的初始化分别如下:

Simple Property:

  All the base persistent classes are derived from the PersistentBase class. This class exposes the AfterConstruction method intended for object initialization. The AfterConstruction method is called only once for an object - after the object is created. Whenever you need to initialize an object, you should override these methods and place the initialization code into its body. As this method is specifically designed for initialization, there is no need to check the current object state when assigning values to the object properties.

Reference Property:

  Initialization of reference properties primarily differs from initialization of simple properties, in that you may need to obtain a reference to an existing object. For this purpose, use the Session.FindObject method of the object 's Session.

Collection Property :

  To populate business object collections, use the XPCollection.Add method.

Calculated Property :

  A calculated property value is automatically updated when the associated property values are changed. To learn how to implement a regular calculated property, refer to the Make a Property Calculable tutorial lesson.

 

Initialize an Object Created via the New Action

  In certain scenarios you may need to initialize only objects created specifically via the New Action. To learn how to do this, refer to the How to: Initialize an Object Created via the New Action help topic.