Skip to main content
.NET 6.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.Xpo.v23.2.dll

Declaration

public BaseObject(
    Session session
)

Parameters

Name Type Description
session Session

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

Remarks

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.

The following code snippets (auto-collected from DevExpress Examples) contain references to the BaseObject(Session) constructor.

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.

See Also