xpo-devexpress-dot-xpo-dot-unitofwork.md
Commits all the changes made to persistent objects to a data store.
Namespace : DevExpress.Xpo
Assembly : DevExpress.Xpo.v25.2.dll
NuGet Package : DevExpress.Xpo
public void CommitChanges()
Public Sub CommitChanges
A Unit of Work tracks every change to every persistent object during a transaction that can affect a data store. Its CommitChanges method commits all the changes made to persistent objects to a data store. The only requirement for this is that the property setters call the XPBaseObject.OnChanged method.
Calling the CommitChanges method automatically calls Session.CommitTransaction (in explicit units of work, ExplicitUnitOfWork.CommitTransaction is called).
Note
If a save operation fails (for example, due to a database constraint violation), the following exceptions can be raised by XPO:
The following code snippets (auto-collected from DevExpress Examples) contain references to the CommitChanges() method.
Note
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.
wpf-data-grid-implement-crud-operations/CS/CodeBehind/XPO/LocalData/Issues/DemoDataHelper.cs#L19
.ToArray();
uow.CommitChanges();
var rnd = new Random(0);
CriteriaOperatorsCheatSheet/CS/CriteriaOperatorCheatSheet/Tests/BaseTest.cs#L16
ConnectionHelper.AddOrder(uow, "FirstName1", 20);
uow.CommitChanges();
}
XPO_how-to-implement-odata4-service-with-xpo-netcore/CS/ODataService/Helpers/ApiHelper.cs#L14
delta.CopyChangedValues(existing);
uow.CommitChanges();
}
XPO_how-to-implement-odata4-service-with-xpo/CS/ODataService/Helpers/ApiHelper.cs#L19
delta.CopyChangedValues(existing);
uow.CommitChanges();
}
how-to-bind-wpf-grid-to-data/CS/CodeBehind/XPO/InfiniteAsyncSource/Issues/DemoDataHelper.cs#L19
.ToArray();
uow.CommitChanges();
var rnd = new Random(0);
how-to-bind-wpf-grid-to-data/VB/CodeBehind/XPO/InfiniteAsyncSource/Issues/DemoDataHelper.vb#L16
End Function).ToArray()
uow.CommitChanges()
Dim rnd = New Random(0)
Public Sub Accept()
euow.CommitChanges()
End Sub
Next current
uow.CommitChanges()
End Using
Try
unitOfWork1.CommitChanges()
Catch exc As Exception
XPO_how-to-persist-metadata-e269/VB/Program.vb#L62
propCustomer.TypeAttributes.Add(attrOrdersCustomer)
uof.CommitChanges()
End Using
See Also