expressappframework-devexpress-dot-expressapp-dot-xpo-dot-xpobjectspace.md
Creates a nested Object Space.
Namespace : DevExpress.ExpressApp.Xpo
Assembly : DevExpress.ExpressApp.Xpo.v25.2.dll
NuGet Package : DevExpress.ExpressApp.Xpo
public override IObjectSpace CreateNestedObjectSpace()
Public Overrides Function CreateNestedObjectSpace As IObjectSpace
| Type | Description |
|---|---|
| IObjectSpace |
An IObjectSpace object that is a created nested Object Space.
|
Use this method to create a nested Object Space for the current Object Space. When committing the changes made within a nested Object Space, they are merged back into the parent Object Space. This allows treating several related operations as a single unified operation.
The code below demonstrates how you can use a nested Object Space to save a new Task object only if its Contact is saved.
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.SystemModule;
using MainDemo.Module.BusinessObjects;
// ...
public class NewObjectController : ObjectViewController<ListView, DemoTask> {
public NewObjectController() {
TargetViewNesting = Nesting.Nested;
}
protected override void OnActivated() {
NewObjectViewController controller = Frame.GetController<NewObjectViewController>();
controller.ObjectCreating += Controller_ObjectCreating;
}
private void Controller_ObjectCreating(object sender, ObjectCreatingEventArgs e) {
IObjectSpace objectSpace = View.ObjectSpace.CreateNestedObjectSpace();
DemoTask task = objectSpace.CreateObject<DemoTask>();
e.ObjectSpace = objectSpace;
e.NewObject = task;
}
}
By default, Nested Object Spaces are used for modal windows with detail views that represent aggregated objects (see AggregatedAttribute). Aggregated objects are considered parts of their owner. When the owner is deleted, its aggregated objects are automatically deleted. Similarly, when the owner is saved, its aggregated objects are also saved. Using nested Object Spaces to represent aggregated object views allows the user to edit these objects in separate windows and choose whether to save or cancel changes (in memory) without immediately saving the owner object. For example:
Object Property Editor
Modal Detail View
Nested Object Spaces are implemented based on Nested Units of Work and inherit their behavior and specifics. Refer to the Nested Units of Work documentation for details.
See Also