The requested page is not available for the requested platform. You are viewing the content for Default platform.

PersistentBase.AfterConstruction() Method

Invoked when the current object is about to be initialized after its creation.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v18.2.dll

Declaration

public virtual void AfterConstruction()
Public Overridable Sub AfterConstruction

Remarks

You can override this method in your PersistentBase descendants to provide custom initialization logic for your persistent objects (see the code example below).


using DevExpress.Xpo;

public class MyDataObject : XPObject {
    public MyDataObject()
        : base() {
        // This constructor is used when an object is loaded from a persistent storage.
        // Do not place any code here.
    }

    public MyDataObject(Session session)
        : base(session) {
        // This constructor is used when an object is loaded from a persistent storage.
        // Do not place any code here.
    }

    public override void AfterConstruction() {
        base.AfterConstruction();
        // Place your initialization code here.
    }
}

The base AfterConstruction method implementation includes only functionality relevant for persistent objects associated with units of work. In essence, the default implementation marks the current object to be saved to a data store if both of the following conditions are met:

  • the current object is associated with a unit of work;
  • the current object is persistent (see XPTypeInfo.IsPersistent).
See Also