Skip to main content
.NET 6.0+

IObjectSpace Interface

Declares members implemented by Object Space.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.1.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public interface IObjectSpace :
    IDisposable

The following members return IObjectSpace objects:

Show 53 links

Remarks

For more information on the Object Space concept, refer to the following class description: BaseObjectSpace.

Follow the steps below to implement a custom Object Space:

  1. Create a new BaseObjectSpace descendant. BaseObjectSpace implements the IObjectSpace members that are not related to the data layer.
  2. Override BaseObjectSpace‘s protected virtual methods you want to customize.
  3. Implement the IObjectSpace members related to the data layer.

You can also inherit one of the BaseObjectSpace descendants.

The following article demonstrates how to create a custom Object Space class and register the custom Object Space Provider for it: How to customize the Object Space behavior in XPO-based XAF applications.

The following example demonstrates how to use the IObjectSpace methods:

using DevExpress.Data.Filtering;
using DevExpress.ExpressApp;
using DevExpress.Persistent.BaseImpl;
using System;
using System.Collections.Generic;
using System.Linq;

//...
public void MethodInsideController(IObjectSpace objectSpace) {
    // In a ViewController, you can use the View.ObjectSpace property to access the current Object Space
    // or call the Application.CreateObjectSpace method to create a new Object Space.
    Person person = objectSpace.FirstOrDefault<Person>(p => p.FirstName == "John" && p.LastName == "Doe");
    if(person != null) {
        // IList<Task> outdatedTasks = objectSpace.GetObjects<Task>(CriteriaOperator.Parse("DueDate < ?", DateTime.Now));
        IQueryable<Task> outdatedTasks = objectSpace.GetObjectsQuery<Task>().Where(t => t.DueDate < DateTime.Now);
        foreach(Task task in outdatedTasks) {
            task.AssignedTo = person;
        }
    }
    objectSpace.CommitChanges();
}
//...

For more information on ways to access an Object Space in different scenarios, refer to the following help topic: Ways to Access an Object Space (the Database Context for CRUD Operations). To learn about Object Space API, see Create, Read, Update and Delete Data.

See Also