Skip to main content

Object Space

  • 3 minutes to read

In XAF applications, all data-aware manipulations are performed via the Object Space. The Object Space is an abstraction on the database context. The Object Space allows you to query or edit data in the transaction. Object Space is an ORM-independent implementation of the well-known Repository and Unit Of Work design patterns.

Object Space members are declared in the IObjectSpace interface. The BaseObjectSpace and CompositeObjectSpace classes implement the common code. XAF includes the following CompositeObjectSpace descendants:


In most cases, you will access Object Space via the IObjectSpace interface and do not need to use these classes directly.

The following example demonstrates how to use Object Space 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;

For more information on ways to access an Object Space in different scenarios, refer to the following help topic: Ways to Implement Business Logic. To learn about Object Space API, see Create, Read, Update and Delete Data.

See Also