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

XPObjectSpace.FindObjectSpaceByObject(Object) Method

Determines the Object Space used to load and save a specified persistent object.

Namespace: DevExpress.ExpressApp.Xpo

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


public static IObjectSpace FindObjectSpaceByObject(
    object obj
Public Shared Function FindObjectSpaceByObject(
    obj As Object
) As IObjectSpace


Name Type Description
obj Object

The object whose Object Space must be determined.


Type Description

An IObjectSpace object which represents the Object Space used to load and save the specified persistent object.


This method is outdated. Instead, create a new Object Space or implement the IObjectSpaceLink interface in your class.

The FindObjectSpaceByObject method returns null (Nothing in VB.NET) if the object specified by the obj parameter belongs to an XPO Session not managed by the ObjectSpace class. This can be the case, for example, if you create an object using a separate Session as follows.

Session theSession = new Session(theDataLayer); 
MyObject theObject = new MyObject(theSession);

Note that you can access certain Object Spaces used internally by XAF via the FindObjectSpaceByObject method. Such Object Spaces should not be used in your applications. One example of such an Object Space is the Object Space used by the Security System.

Using such code in your applications may lead to undesired side-effects. So, instead of using an internal Object Space, create a new Object Space and perform the required actions with it:

using(ObjectSpace objectSpace = application.CreateObjectSpace(typeof(MyClass))) {
//some code which performs actions using the objectSpace Object Space 
See Also