PersistentBase.AfterConstruction() Method
Invoked when the current object is about to be initialized after its creation.
Namespace: DevExpress.Xpo
Assembly: DevExpress.Xpo.v19.2.dll
Declaration
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).
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the AfterConstruction() method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.