Interface IUnitOfWork
- Namespace
- Cratis.Chronicle.Transactions
- Assembly
- Cratis.Chronicle.dll
Represents a unit of work.
public interface IUnitOfWork : IDisposable
- Inherited Members
Properties
CorrelationId
Gets the CorrelationId for the IUnitOfWork.
CorrelationId CorrelationId { get; }
Property Value
IsCompleted
Gets the value indicating whether the unit of work is completed.
bool IsCompleted { get; }
Property Value
Remarks
Unit of work being completed is semantically equal to it being disposed.
IsSuccess
Gets a value indicating whether the IUnitOfWork was successful.
bool IsSuccess { get; }
Property Value
Methods
AddEvent(EventSequenceId, EventSourceId, object, Causation, EventStreamType?, EventStreamId?, EventSourceType?)
Add an event that has occurred to the IUnitOfWork.
void AddEvent(EventSequenceId eventSequenceId, EventSourceId eventSourceId, object @event, Causation causation, EventStreamType? eventStreamType = null, EventStreamId? eventStreamId = null, EventSourceType? eventSourceType = null)
Parameters
eventSequenceId
EventSequenceIdThe EventSequenceId for the event.
eventSourceId
EventSourceIdThe EventSourceId for the event.
event
objectThe event that has occurred.
causation
CausationThe Causation for the event.
eventStreamType
EventStreamTypeOptional EventStreamType for the event, will default to the All stream if not set.
eventStreamId
EventStreamIdOptional EventStreamId for the event, will default to Default is not set.
eventSourceType
EventSourceTypeOptional EventSourceType for the event, will default to Default is not set.
Commit()
Commit the IUnitOfWork.
Task Commit()
Returns
- Task
Awaitable task.
GetAppendErrors()
Get any errors that have occurred while attempting to commit in the IUnitOfWork.
IEnumerable<AppendError> GetAppendErrors()
Returns
- IEnumerable<AppendError>
A collection of AppendError.
GetConstraintViolations()
Gets the constraint violations that have occurred in the IUnitOfWork.
IEnumerable<ConstraintViolation> GetConstraintViolations()
Returns
- IEnumerable<ConstraintViolation>
A collection of ConstraintViolation.
GetEvents()
Get the events that have occurred in the IUnitOfWork.
IEnumerable<object> GetEvents()
Returns
- IEnumerable<object>
A collection of events.
OnCompleted(Action<IUnitOfWork>)
Set callback to be called when completed.
void OnCompleted(Action<IUnitOfWork> callback)
Parameters
callback
Action<IUnitOfWork>The callback to call.
Rollback()
Rollback the IUnitOfWork.
Task Rollback()
Returns
- Task
Awaitable task.
TryGetLastCommittedEventSequenceNumber(out EventSequenceNumber?)
Try to get the EventSequenceNumber of the last committed event.
bool TryGetLastCommittedEventSequenceNumber(out EventSequenceNumber? eventSequenceNumber)
Parameters
eventSequenceNumber
EventSequenceNumberThe outputted EventSequenceNumber of the last committed event.
Returns
- bool
True if events were committed, false if not.