Table of Contents

Class UnitOfWork

Namespace
DevExpress.Xpo
Assembly
DevExpress.Xpo.v24.1.dll

Maintains a list of persistent objects that are affected by a transaction. Keeps track of every change to every persistent object during a transaction that can affect a data store.

public class UnitOfWork : Session, IComponent, IDisposable, ISupportInitialize, IPersistentValueExtractor, ISessionProvider, IObjectLayerProvider, IDataLayerProvider, IXPDictionaryProvider, IWideDataStorage, ICommandChannel, ICommandChannelAsync
Inheritance
UnitOfWork
Implements
ICommandChannel
ICommandChannelAsync
Derived
Inherited Members
Extension Methods

Constructors

UnitOfWork()

Initializes a new instance of the UnitOfWork class with default settings.

public UnitOfWork()

UnitOfWork(IDataLayer, params IDisposable[])

Initializes a new instance of the UnitOfWork class with the specified settings.

public UnitOfWork(IDataLayer layer, params IDisposable[] disposeOnDisconnect)

Parameters

layer IDataLayer

An object which implements 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 unit of work is disconnected.

UnitOfWork(IObjectLayer, params IDisposable[])

Initializes a new instance of the UnitOfWork class with specified settings.

public UnitOfWork(IObjectLayer layer, params IDisposable[] disposeOnDisconnect)

Parameters

layer IObjectLayer

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

UnitOfWork(XPDictionary)

Initializes a new instance of the UnitOfWork class with the specified dictionary.

public UnitOfWork(XPDictionary dictionary)

Parameters

dictionary XPDictionary

An XPDictionary descendant that provides metadata on persistent objects in a data store.

UnitOfWork(IContainer)

Initializes a new instance of the UnitOfWork class and adds it to a form’s container.

public UnitOfWork(IContainer container)

Parameters

container IContainer

An IContainer object, which is the owner container of the created UnitOfWork instance.

UnitOfWork(IServiceProvider)

Initializes a new instance of the UnitOfWork class with specified settings.

public UnitOfWork(IServiceProvider serviceProvider)

Parameters

serviceProvider IServiceProvider

An object that implements the IServiceProvider interface. This object is assigned to the Session.ServiceProvider property.

UnitOfWork(IServiceProvider, IDataLayer, params IDisposable[])

Initializes a new instance of the UnitOfWork class with specified settings.

public UnitOfWork(IServiceProvider serviceProvider, IDataLayer layer, params IDisposable[] disposeOnDisconnect)

Parameters

serviceProvider IServiceProvider

An object that implements the IServiceProvider interface. This object is assigned to the Session.ServiceProvider property.

layer IDataLayer

An object which implements 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 unit of work is disconnected.

UnitOfWork(IServiceProvider, IObjectLayer, params IDisposable[])

Initializes a new instance of the UnitOfWork class with specified settings.

public UnitOfWork(IServiceProvider serviceProvider, IObjectLayer layer, params IDisposable[] disposeOnDisconnect)

Parameters

serviceProvider IServiceProvider

An object that implements the IServiceProvider interface. This object is assigned to the Session.ServiceProvider property.

layer IObjectLayer

An object which implements 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 unit of work is disconnected.

UnitOfWork(IServiceProvider, XPDictionary)

Initializes a new instance of the UnitOfWork class with specified settings.

public UnitOfWork(IServiceProvider serviceProvider, XPDictionary dictionary)

Parameters

serviceProvider IServiceProvider

An object that implements the IServiceProvider interface. This object is assigned to the Session.ServiceProvider property.

dictionary XPDictionary

An XPDictionary object, which is the metadata provider to be used by the newly instantiated session. This value is assigned to the Session.Dictionary property.

UnitOfWork(IServiceProvider, IContainer)

Initializes a new instance of the UnitOfWork class with specified settings.

public UnitOfWork(IServiceProvider serviceProvider, IContainer container)

Parameters

serviceProvider IServiceProvider

An object that implements the IServiceProvider interface. This object is assigned to the Session.ServiceProvider property.

container IContainer

An IContainer object, which is the owner container of the created Session instance.

Properties

IsUnitOfWork

protected override bool IsUnitOfWork { get; }

Property Value

bool

Methods

CommitChanges()

Commits all the changes made to persistent objects to a data store.

public void CommitChanges()

CommitChangesAsync(AsyncCommitCallback)

Asynchronously commits all the changes made to persistent objects to a data store and notifies upon completion.

public object CommitChangesAsync(AsyncCommitCallback callback)

Parameters

callback AsyncCommitCallback

A AsyncCommitCallback delegate to be called after the changes have been saved. Use the 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.

CommitChangesAsync(CancellationToken)

Asynchronously commits object changes made in a specified session and notifies upon completion.

public Task CommitChangesAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A CancellationToken object that delivers a cancellation notice to the running operation.

Returns

Task

A Task that commits specified object changes.

ReloadChangedObjects()

Reloads the state of persistent objects modified within the current UnitOfWork from the data store.

public void ReloadChangedObjects()