The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+

BaseObjectSpace Class

A base class for the classes that implement the IObjectSpace interface.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v19.2.dll

Declaration

public class BaseObjectSpace :
    IObjectSpace,
    IDisposable
Public Class BaseObjectSpace
    Implements IObjectSpace,
               IDisposable
public class BaseObjectSpace :
    IObjectSpace,
    IDisposable
Public Class BaseObjectSpace
    Implements IObjectSpace,
               IDisposable
public class BaseObjectSpace :
    IObjectSpace,
    IDisposable
Public Class BaseObjectSpace
    Implements IObjectSpace,
               IDisposable

Remarks

When using XAF for building business applications, you can choose which ORM system to utilize. Currently, it can be either the eXpressPersistent Objects library (XPO) or the Entity Framework. Historically, the eXpressApp Framework has been based on XPO. In release 2012v1, we started to support the Entity Framework. For this purpose, we have made XAF core independent from any dependencies on a specific data layer. Now, the classes that are required to interact with a particular data layer are contained in separate libraries, DevExpress.ExpressApp.Xpo and DevExpress.ExpressApp.EF. You can create a custom library for working with an alternative ORM system. All of these libraries should contain an Object Space class. It represents an instrument that allows managing a cache with persistent objects. For instance, the DevExpress.ExpressApp.Xpo library contains the XPObjectSpace class. It is a wrapper over the UnitOfWork class, which represents a cache with persistent objects in XPO. The DevExpress.ExpressApp.EF library contains the EFObjectSpace class. It is a wrapper over the ObjectContext, which represents a container for in-memory objects in the Entity Framework. Any Object Space class must support the IObjectSpace interface. This interface exposes the members that do not depend on the used ORM system and the members that are data layer-specific. XAF supplies the BaseObjectSpace class. Its members can serve as the implementation of the IObjectSpace interface members that do not depend on the ORM system used. Both the XPObjectSpace and EFObjectSpace classes are inherited from the BaseObjectSpace class to support the IObjectSpace interface.

A particular Object Space object is assigned for each View. It helps to retrieve and create objects represented by a View. Moreover, an Object Space tracks all changes made to its objects and saves them to the database when required. To access a View's Object Space, use the View.ObjectSpace property. In addition, you can access the Object Space of an object collection to manage its entire content and individual objects. For this purpose, use the CollectionSourceBase.ObjectSpace property.

Note

The View.ObjectSpace property is not supposed to be used in scenarios where a large amount of data is processed, created or deleted. Instead, use an independent Object Space which is not used by a View. Such an Object Space can be instantiated via the XafApplication.CreateObjectSpace method.

Use an ObjectSpace object's BaseObjectSpace.CreateObject method to create persistent objects. In this instance, this Object Space will manage the newly created object's life cycle. All the changes made to this object will be tracked until the Object Space's BaseObjectSpace.CommitChanges method is invoked. When executing custom features, use the CommitChanges method to save all the changes made to the persistent objects belonging to the current Object Space. The changes include: creating, modifying or deleting an object (see BaseObjectSpace.IsModified, BaseObjectSpace.SetModified, BaseObjectSpace.ModifiedChanged, and BaseObjectSpace.Delete). For instance, the CommitChanges method is called when executing the Save, SaveAndClose and other built-in Actions.

The Object Space class also allows you to perform auxiliary operations with objects: search for the required object (BaseObjectSpace.FindObject), getting information on the required object (IObjectSpace.GetKeyPropertyName, IObjectSpace.GetKeyPropertyType and IObjectSpace.GetKeyValue), getting the required objects (BaseObjectSpace.GetObject and BaseObjectSpace.GetObjectByKey), and others.

When creating a new View, you will need to create a new Object Space. For this purpose, use the XafApplication.CreateObjectSpace method. Note that in specific situations, you can create a View in the current Object Space. For instance, nested List Views that represent non-aggregated collections are created in the parent View's Object Space.

Implements

See Also