Back to Devexpress

UnitOfWork.CommitChanges() Method

xpo-devexpress-dot-xpo-dot-unitofwork.md

latest6.1 KB
Original Source

UnitOfWork.CommitChanges() Method

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

Declaration

csharp
public void CommitChanges()
vb
Public Sub CommitChanges

Remarks

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

csharp
.ToArray();
uow.CommitChanges();
var rnd = new Random(0);

CriteriaOperatorsCheatSheet/CS/CriteriaOperatorCheatSheet/Tests/BaseTest.cs#L16

csharp
ConnectionHelper.AddOrder(uow, "FirstName1", 20);
    uow.CommitChanges();
}

XPO_how-to-implement-odata4-service-with-xpo-netcore/CS/ODataService/Helpers/ApiHelper.cs#L14

csharp
delta.CopyChangedValues(existing);
    uow.CommitChanges();
}

XPO_how-to-implement-odata4-service-with-xpo/CS/ODataService/Helpers/ApiHelper.cs#L19

csharp
delta.CopyChangedValues(existing);
    uow.CommitChanges();
}

how-to-bind-wpf-grid-to-data/CS/CodeBehind/XPO/InfiniteAsyncSource/Issues/DemoDataHelper.cs#L19

csharp
.ToArray();
uow.CommitChanges();
var rnd = new Random(0);

how-to-bind-wpf-grid-to-data/VB/CodeBehind/XPO/InfiniteAsyncSource/Issues/DemoDataHelper.vb#L16

vb
End Function).ToArray()
uow.CommitChanges()
Dim rnd = New Random(0)

XPO_how-to-generate-a-sequential-number-for-a-business-object-within-a-database-transaction-e2620/VB/ExplicitUnitOfWorkDemo/SequenceGenerator.vb#L20

vb
Public Sub Accept()
    euow.CommitChanges()
End Sub

XPO_how-to-import-a-large-data-set-using-xpo-efficiently-within-a-transaction-t333879/VB/XpoImport - VB/XpoImportHelper.vb#L35

vb
Next current
    uow.CommitChanges()
End Using

XDL_how-to-convert-the-criteriaoperator-to-a-lambda-expression-to-use-it-for-iqueryable-e2596/VB/WindowsFormsApplication152/Form1.vb#L55

vb
Try
    unitOfWork1.CommitChanges()
Catch exc As Exception

XPO_how-to-persist-metadata-e269/VB/Program.vb#L62

vb
propCustomer.TypeAttributes.Add(attrOrdersCustomer)
    uof.CommitChanges()
End Using

See Also

CommitChangesAsync

UnitOfWork Class

UnitOfWork Members

DevExpress.Xpo Namespace