Table of Contents

Interface ITransactionScope

Namespace
Excalibur.Data.Persistence
Assembly
Excalibur.Data.Abstractions.dll

Defines a transaction scope for managing distributed transactions across multiple providers.

public interface ITransactionScope : IAsyncDisposable, IDisposable
Inherited Members

Remarks

This interface follows the ISP pattern with ≤5 methods. Advanced capabilities (savepoints, nested scopes, callbacks) are available via sub-interfaces:

Implementations that support these capabilities should also implement the sub-interfaces. Consumers can check via pattern matching: if (scope is ITransactionScopeAdvanced advanced) { ... }

Properties

IsolationLevel

Gets the isolation level of the transaction.

IsolationLevel IsolationLevel { get; }

Property Value

IsolationLevel

The isolation level of the transaction.

StartTime

Gets the transaction start time.

DateTimeOffset StartTime { get; }

Property Value

DateTimeOffset

The transaction start time.

Status

Gets the transaction status.

TransactionStatus Status { get; }

Property Value

TransactionStatus

The transaction status.

Timeout

Gets or sets the transaction timeout.

TimeSpan Timeout { get; set; }

Property Value

TimeSpan

The transaction timeout.

TransactionId

Gets the unique identifier for this transaction scope.

string TransactionId { get; }

Property Value

string

The unique identifier for this transaction scope.

Methods

CommitAsync(CancellationToken)

Commits the transaction across all enlisted providers.

Task CommitAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The cancellation token.

Returns

Task

A task representing the asynchronous operation.

EnlistConnectionAsync(IDbConnection, CancellationToken)

Enlists a database connection in the transaction.

Task EnlistConnectionAsync(IDbConnection connection, CancellationToken cancellationToken)

Parameters

connection IDbConnection

The connection to enlist.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

A task representing the asynchronous operation.

EnlistProviderAsync(IPersistenceProvider, CancellationToken)

Enlists a persistence provider in the transaction.

Task EnlistProviderAsync(IPersistenceProvider provider, CancellationToken cancellationToken)

Parameters

provider IPersistenceProvider

The provider to enlist.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

A task representing the asynchronous operation.

GetEnlistedProviders()

Gets all enlisted providers.

IEnumerable<IPersistenceProvider> GetEnlistedProviders()

Returns

IEnumerable<IPersistenceProvider>

Collection of enlisted providers.

RollbackAsync(CancellationToken)

Rolls back the transaction across all enlisted providers.

Task RollbackAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The cancellation token.

Returns

Task

A task representing the asynchronous operation.