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

Syntax

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).

Note

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

See Also