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.v18.2.dll

Declaration

public BaseObject(
    Session session
)
Public Sub New(
    session As Session
)

Parameters

Type Name 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:

[DefaultClassOptions]
    public class MyDomainObject : BaseObject {
        public MyDomainObject(Session session) : base(session) { }
}
Note

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