Skip to main content
A newer version of this page is available. .

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.1.dll

Declaration

public static IObjectSpace FindObjectSpaceByObject(
    object obj
)

Parameters

Name Type Description
obj Object

The object whose Object Space must be determined.

Returns

Type Description
IObjectSpace

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

Remarks

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 
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the FindObjectSpaceByObject(Object) method.

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