ExplicitUnitOfWork.BeginTransaction() Method
Marks the starting point of a database level transaction.
Namespace: DevExpress.Xpo
Assembly: DevExpress.Xpo.v24.1.dll
NuGet Packages: DevExpress.Win.PivotGrid, DevExpress.Win.TreeMap, DevExpress.Xpo
NuGet Package: DevExpress.Xpo
Declaration
Remarks
The BeginTransaction method represents the point at which the data referenced by an explicit unit of work is consistent. All data modifications made after calling the BeginTransaction method can be rolled back. This allows data to be returned to this known state of consistency.
An explicit unit of work automatically calls the BeginTransaction method when a persistent object is about to be loaded from a database for the first time. You can manually call this method whenever you see it fit.
Once started, a database level transaction lasts until one of the following occurs:
- The modifications are committed via the ExplicitUnitOfWork.CommitTransaction, ExplicitUnitOfWork.CommitTransactionAsync, UnitOfWork.CommitChanges, or UnitOfWork.CommitChangesAsync method.
- The modifications are discarded via the Session.RollbackTransaction method or by disposing of ExplicitUnitOfWork.
Calling the BeginTransaction method raises the Session.BeforeBeginTransaction event. Once a database level transaction is started, the Session.AfterBeginTransaction event is raised.
Note
The BeginTransaction method throws an exception if a database level transaction has already been started.