Skip to main content
.NET 6.0+

IObjectSpace.CommitChanges() Method

Saves all the changes made to the persistent objects belonging to the current Object Space to the database.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.1.dll

NuGet Package: DevExpress.ExpressApp


void CommitChanges()


When working with persistent objects, the changes that you make are not saved immediately. Each object change is tracked. To save all the tracked changes, the CommitChanges method is called. After calling this method, the track list is emptied and the IObjectSpace.IsModified property is set to false.

In default scenarios, this method is automatically called. But all custom manipulations that you perform with persistent objects must be saved manually via this method.

When implementing the IObjectSpace interface in the BaseObjectSpace class’s descendant, override the DoCommit method. It is invoked by the BaseObjectSpace.CommitChanges method, in which the following events raised:

  • IObjectSpace.Committing

    Raised before committing the changes. It is intended to prevent the commit performed by the CommitChanges method.

  • IObjectSpace.CustomCommitChanges

    Raised before committing the changes. It is intended to perform a custom commit instead of a default one.

  • IObjectSpace.Committed

    Raised after committing the changes. It is intended to perform post actions after the commit.

In the DoCommit method, force saving changes using a container for in-memory objects (see UnitOfWork.CommitChanges in XPO).


An Object Space object commits only the objects that were created with its help. Otherwise, an exception is raised.

The following example uses a Parametrized Action to search for a Person by LastName, and then assigns all deferred tasks to that person.

using System.Collections.Generic;
using DevExpress.Data.Filtering;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.Base.General;
using DevExpress.Persistent.BaseImpl;
using MainDemo.Module.BusinessObjects;
// ...
public class AssignTasksController : ViewController {
    public AssignTasksController() {
        TargetObjectType = typeof(DemoTask);
        ParametrizedAction assignTasksAction = new ParametrizedAction(
            this, "AssignTasks", PredefinedCategory.Edit, typeof(string));
        assignTasksAction.Execute += AssignTasksAction_Execute;
    private void AssignTasksAction_Execute(object sender, ParametrizedActionExecuteEventArgs e) {
        using(IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(Person))) {
            string personParamValue = e.ParameterCurrentValue as string;
            Person person = objectSpace.FirstOrDefault<Person>(p => p.LastName.Contains(personParamValue));
            if(person != null) {
                CriteriaOperator taskCriteria = CriteriaOperator.Parse("[Status] = ?", TaskStatus.Deferred);
                IList<DemoTask> tasks = objectSpace.GetObjects<DemoTask>(taskCriteria);
                foreach(DemoTask task in tasks) {
                    task.AssignedTo = person;

The following code snippets (auto-collected from DevExpress Examples) contain references to the CommitChanges() method.


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