Class UnitOfWorkManager
- Namespace
- Cratis.Chronicle.Transactions
- Assembly
- Cratis.Chronicle.dll
Represents an implementation of IUnitOfWorkManager.
public class UnitOfWorkManager : IUnitOfWorkManager
- Inheritance
-
UnitOfWorkManager
- Implements
- Inherited Members
- Extension Methods
Constructors
UnitOfWorkManager(IEventStore, IActivitySource<UnitOfWork>?)
Initializes a manager with compatibility staging behavior.
public UnitOfWorkManager(IEventStore eventStore, IActivitySource<UnitOfWork>? activitySource = null)
Parameters
eventStoreIEventStoreThe event store.
activitySourceIActivitySource<UnitOfWork>Optional activity source.
UnitOfWorkManager(IEventStore, IActivitySource<UnitOfWork>?, UnitOfWorkLifecyclePolicy, ILogger<UnitOfWork>?)
Initializes a new instance of the UnitOfWorkManager class.
public UnitOfWorkManager(IEventStore eventStore, IActivitySource<UnitOfWork>? activitySource, UnitOfWorkLifecyclePolicy lifecyclePolicy, ILogger<UnitOfWork>? logger = null)
Parameters
eventStoreIEventStoreThe event store.
activitySourceIActivitySource<UnitOfWork>Optional activity source.
lifecyclePolicyUnitOfWorkLifecyclePolicyThe policy for staging after completion begins.
loggerILogger<UnitOfWork>Optional logger for late staging diagnostics.
Properties
Current
Gets the current IUnitOfWork, scoped to the current async context.
public IUnitOfWork Current { get; }
Property Value
Exceptions
- NoUnitOfWorkHasBeenStarted
If no unit of work has been started.
HasCurrent
Gets a value indicating whether or not there is a current IUnitOfWork.
public bool HasCurrent { get; }
Property Value
Methods
Begin(CorrelationId)
Begin a new IUnitOfWork with a specific CorrelationId for the current async context.
public IUnitOfWork Begin(CorrelationId correlationId)
Parameters
correlationIdCorrelationIdThe CorrelationId to use for the IUnitOfWork.
Returns
- IUnitOfWork
A new IUnitOfWork.
SetCurrent(IUnitOfWork)
Set the current IUnitOfWork.
public void SetCurrent(IUnitOfWork unitOfWork)
Parameters
unitOfWorkIUnitOfWorkThe IUnitOfWork to set as current.
TryGetFor(CorrelationId, out IUnitOfWork)
Try to get the IUnitOfWork for a specific CorrelationId.
public bool TryGetFor(CorrelationId correlationId, out IUnitOfWork unitOfWork)
Parameters
correlationIdCorrelationIdThe CorrelationId to get the IUnitOfWork for.
unitOfWorkIUnitOfWorkThe IUnitOfWork if it was found, otherwise null.
Returns
- bool
True if it was found, false if not.