Class ExplicitUnitOfWork
- Namespace
- DevExpress.Xpo
- Assembly
- DevExpress.Xpo.v24.1.dll
The ‘unit of work’ that uses long database level transaction to allow you to simplify the management of object changes and to access modified objects without having to commit the changes beforehand.
public class ExplicitUnitOfWork : UnitOfWork, IComponent, IDisposable, ISupportInitialize, IPersistentValueExtractor, ISessionProvider, IObjectLayerProvider, IDataLayerProvider, IXPDictionaryProvider, IWideDataStorage, ICommandChannel, ICommandChannelAsync
- Inheritance
-
ExplicitUnitOfWork
- Implements
-
ICommandChannelICommandChannelAsync
- Inherited Members
-
Session.EvaluateInTransactionAsync<ClassType>(CriteriaOperator, CriteriaOperator, CancellationToken)
- Extension Methods
Constructors
ExplicitUnitOfWork()
Initializes a new instance of the ExplicitUnitOfWork class with the default settings.
public ExplicitUnitOfWork()
ExplicitUnitOfWork(IDataLayer, params IDisposable[])
Initializes a new instance of the ExplicitUnitOfWork class with the specified settings.
public ExplicitUnitOfWork(IDataLayer layer, params IDisposable[] disposeOnDisconnect)
Parameters
layer
IDataLayerAn object implementing the IDataLayer interface. This value is assigned to the Session.DataLayer property.
disposeOnDisconnect
IDisposable[]An array of objects that implement the IDisposable interface. These objects are automatically disposed of when the explicit unit of work is disconnected.
ExplicitUnitOfWork(IObjectLayer, params IDisposable[])
Initializes a new instance of the ExplicitUnitOfWork class with specified settings.
public ExplicitUnitOfWork(IObjectLayer layer, params IDisposable[] disposeOnDisconnect)
Parameters
layer
IObjectLayerAn object implementing the IObjectLayer interface. This value is assigned to the Session.ObjectLayer property.
disposeOnDisconnect
IDisposable[]An array of objects that implement the IDisposable interface. These objects are automatically disposed of when the explicit unit of work is disconnected.
ExplicitUnitOfWork(XPDictionary)
Initializes a new instance of the ExplicitUnitOfWork class with the specified dictionary.
public ExplicitUnitOfWork(XPDictionary dictionary)
Parameters
dictionary
XPDictionaryAn XPDictionary descendant that provides metadata on persistent objects in a data store.
ExplicitUnitOfWork(IContainer)
Initializes a new instance of the ExplicitUnitOfWork class and adds it to a form’s container.
public ExplicitUnitOfWork(IContainer container)
Parameters
container
IContainerAn IContainer object, which is the owner container of the created ExplicitUnitOfWork instance.
ExplicitUnitOfWork(IServiceProvider)
Initializes a new instance of the ExplicitUnitOfWork class with specified settings.
public ExplicitUnitOfWork(IServiceProvider serviceProvider)
Parameters
serviceProvider
IServiceProviderAn object that implements the IServiceProvider interface. This object is assigned to the Session.ServiceProvider property.
ExplicitUnitOfWork(IServiceProvider, IDataLayer, params IDisposable[])
Initializes a new instance of the ExplicitUnitOfWork class with specified settings.
public ExplicitUnitOfWork(IServiceProvider serviceProvider, IDataLayer layer, params IDisposable[] disposeOnDisconnect)
Parameters
serviceProvider
IServiceProviderAn object that implements the IServiceProvider interface. This object is assigned to the Session.ServiceProvider property.
layer
IDataLayerAn object implementing the IDataLayer interface. This value is assigned to the Session.DataLayer property.
disposeOnDisconnect
IDisposable[]An array of objects that implement the IDisposable interface. These objects are automatically disposed of when the explicit unit of work is disconnected.
ExplicitUnitOfWork(IServiceProvider, IObjectLayer, params IDisposable[])
Initializes a new instance of the ExplicitUnitOfWork class with specified settings.
public ExplicitUnitOfWork(IServiceProvider serviceProvider, IObjectLayer layer, params IDisposable[] disposeOnDisconnect)
Parameters
serviceProvider
IServiceProviderAn object that implements the IServiceProvider interface. This object is assigned to the Session.ServiceProvider property.
layer
IObjectLayerAn object which implements the IObjectLayer interface. This value is assigned to the Session.ObjectLayer property.
disposeOnDisconnect
IDisposable[]An array of objects that implement the System.IDisposable interface. These objects are automatically disposed of when the session is disconnected.
ExplicitUnitOfWork(IServiceProvider, XPDictionary)
Initializes a new instance of the ExplicitUnitOfWork class with specified settings.
public ExplicitUnitOfWork(IServiceProvider serviceProvider, XPDictionary dictionary)
Parameters
serviceProvider
IServiceProviderAn object that implements the IServiceProvider interface. This object is assigned to the Session.ServiceProvider property.
dictionary
XPDictionaryAn XPDictionary descendant that provides metadata on persistent objects in a data store.
ExplicitUnitOfWork(IServiceProvider, IContainer)
Initializes a new instance of the ExplicitUnitOfWork class with specified settings.
public ExplicitUnitOfWork(IServiceProvider serviceProvider, IContainer container)
Parameters
serviceProvider
IServiceProviderAn object that implements the IServiceProvider interface. This object is assigned to the Session.ServiceProvider property.
container
IContainerAn IContainer object, which is the owner container of the created UnitOfWork instance.
Properties
InTransaction
Indicates whether the explicit unit of work has started a database level transaction or tracked data modifications.
public override bool InTransaction { get; }
Property Value
- bool
true if a database level transaction is started, or any modifications have been made within a unit of work; otherwise, false.
IsInTransactionMode
protected override bool IsInTransactionMode { get; }
Property Value
Methods
BeginFlushChanges()
protected override IList BeginFlushChanges()
Returns
BeginFlushChangesAsync(int, CancellationToken)
protected override Task<IList> BeginFlushChangesAsync(int asyncOperationId, CancellationToken cancellationToken = default)
Parameters
asyncOperationId
intcancellationToken
CancellationToken
Returns
BeginTransaction()
Marks the starting point of a database level transaction.
public override void BeginTransaction()
CommitTransaction()
Completes a database level transaction and commits changes made within it.
public override void CommitTransaction()
CommitTransactionAsync(AsyncCommitCallback)
Asynchronously completes a database level transaction and notifies upon completion.
public override object CommitTransactionAsync(AsyncCommitCallback callback)
Parameters
callback
AsyncCommitCallbackAn AsyncCommitCallback delegate to be called after the changes have been saved to a data store. Use a callback to store the exception information passed as a parameter, and use this information later to raise the exception again, within the original thread. Do not raise exceptions or modify persistent objects within a callback.
Returns
- object
An object identifying the current asynchronous operation, intended for internal use.
CommitTransactionAsync(CancellationToken)
Asynchronously commits object changes made within a transaction, completes the transaction, and notifies upon completion.
public override Task CommitTransactionAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenA CancellationToken object that delivers a cancellation notice to the running operation.
Returns
- Task
A Task that commits object changes made within a transaction and completes the transaction.
OnAfterBeginTrackingChanges()
protected override void OnAfterBeginTrackingChanges()
OnAfterDropChanges()
protected override void OnAfterDropChanges()
OnAfterFlushChanges()
protected override void OnAfterFlushChanges()
OnBeforeBeginTrackingChanges()
protected override void OnBeforeBeginTrackingChanges()
OnBeforeDropChanges()
protected override void OnBeforeDropChanges()
OnBeforeFlushChanges()
protected override void OnBeforeFlushChanges()
OnFailedFlushChanges(Exception)
protected override bool OnFailedFlushChanges(Exception ex)
Parameters
ex
Exception
Returns
RollbackTransaction()
Rolls back a database level transaction to its starting point, discarding any changes made within it.
public override void RollbackTransaction()
RollbackTransactionAsync(CancellationToken)
public Task RollbackTransactionAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationToken