.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+

BaseObject(Session) Constructor

Used to initialize a new instance of a BaseObject descendant, in a particular Session.

Namespace: DevExpress.Persistent.BaseImpl

Assembly: DevExpress.Persistent.BaseImpl.v21.1.dll


public BaseObject(
    Session session


Name Type Description
session Session

A DevExpress.Xpo.Session object which represents a persistent object’s cache where the business object will be instantiated.


The eXpress Persistent Objects, an object persistence framework used by XAF, demands that each persistent object must be tied to a Session. So, when implementing a business class derived from the BaseObject class, ensure that the business class has a constructor which takes a Session-type parameter and passes it to the BaseObject class constructor. If you create a new business object declaration in an XAF application via the XAF Business Object | XPO Business Object template, the created declaration automatically contains such a constructor:

    public class MyDomainObject : BaseObject {
        public MyDomainObject(Session session) : base(session) { }


XAF manages persistent objects via Object Spaces (see XPObjectSpace). An Object Space exposes a Session object via its XPObjectSpace.Session property. So, if you need to create a new Session to interact with the database used by an XAF application, instantiate an XPObjectSpace via the XafApplication.CreateObjectSpace method, and use its XPObjectSpace.Session property.

See Also