Skip to main content
.NET 6.0+

XPObjectSpace Class

An Object Space that is used for data manipulation using the DevExpress ORM Tool (XPO).

Namespace: DevExpress.ExpressApp.Xpo

Assembly: DevExpress.ExpressApp.Xpo.v23.2.dll

NuGet Package: DevExpress.ExpressApp.Xpo

Declaration

public class XPObjectSpace :
    CompositeObjectSpace,
    IDataLockingManager,
    IAsyncServerDataSourceCreator,
    ISessionProvider,
    IObjectLayerProvider,
    IXPDictionaryProvider,
    IDataLayerProvider,
    IObjectSpaceAsync,
    ISupportServerViews,
    IQuerySupport,
    ICriteriaProcessor

Remarks

When an XAF application uses XPO as an ORM layer, an Object Space of the XPObjectSpace class is created. This class is a wrapper over of the Unit of Work which is used in XPO as a cache for persistent objects. To access the UnitOfWork used by the current Object Space, use the XPObjectSpace.Session property. The Object Space uses its UnitOfWork to create, manage and delete persistent objects.

The UnitofWork tracks every change to every persistent object. All the changes made to persistent objects are automatically saved to the database by making a single method call (see BaseObjectSpace.CommitChanges). For details, refer to the Session and Unit of Work topics from the XPO documentation. To be sure that changes made to a persistent object’s properties are cached and then committed with other changes, call the SetPropertyValue method with three parameters in the property setters. This is the recommended way to implement persistent properties if you want changes to be recognized automatically in Units of Work with which XAF’s Object Spaces work. If you need to track a custom object change, use the BaseObjectSpace.SetModified method.

XPObjectSpace works with collections of the XPCollection type when it is required to load all required objects to a client at once, and with the XPServerCollectionSource collection type when loading objects in small portions on demand.

To create a new Object Space, use the XafApplication.CreateObjectSpace(Type) method. This method finds a suitable Object Space Provider for the specified business object type. Different Object Space Provider types return different BaseObjectSpace descendants. For more information about Object Space and Object Space Provider types, see the following topics:

See Also