Referencia Pública de API .NETL2 Transversal y FiabilidadEstableAOT: Completo

EricksonLopez.Transaction

High-performance, explicit, composable, and Native AOT-ready relational database transaction coordinator for modern .NET 8, .NET 9, and .NET 10 applications.

17 namespaces67 tipos277 miembrosGenerado desde XML docs y ensamblados · UTC 2026-12-01

Mostrando 67 de 67 tipos (277 miembros)

EricksonLopez.Transaction#

19
class

AutonomousTransactionRunner

Ensamblado: EricksonLopez.Transaction
public sealed class AutonomousTransactionRunner : IAutonomousTransactionRunner
Implementa: IAutonomousTransactionRunner

Default implementation of `IAutonomousTransactionRunner` that executes critical operations inside an independent physical connection and transaction (`NestedTransactionBehavior.RequireNew`), ensuring durable commits even when an outer ambient transaction rolls back.

Miembros (5)

  • constructorAutonomousTransactionRunner
    public AutonomousTransactionRunner(ITransactionManager transactionManager)

    Initializes a new instance of the `AutonomousTransactionRunner` class.

    transactionManager: ITransactionManager
    The underlying transaction coordinator.

    Exceptions: ArgumentNullException: `transactionManager` is `null`.

  • methodExecuteAsync
    public async Task ExecuteAsync(Func<CancellationToken, Task> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes the specified asynchronous action inside an independent autonomous transaction and commits it durably.

    operation: Func<CancellationToken, Task>
    The asynchronous operation to execute within the autonomous transaction scope.
    options: TransactionOptions?
    Optional transaction configuration overrides (nested behavior is always forced to `NestedTransactionBehavior.RequireNew`).
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

  • methodExecuteAsync
    public async Task ExecuteAsync(Func<ITransactionContext, CancellationToken, Task> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes the specified asynchronous action inside an independent autonomous transaction and commits it durably.

    operation: Func<ITransactionContext, CancellationToken, Task>
    The asynchronous operation to execute within the autonomous transaction scope.
    options: TransactionOptions?
    Optional transaction configuration overrides (nested behavior is always forced to `NestedTransactionBehavior.RequireNew`).
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

  • methodExecuteAsync<TResult>
    public async Task<TResult> ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes the specified asynchronous function inside an independent autonomous transaction, commits it durably, and returns its result.

    operation: Func<CancellationToken, Task<TResult>>
    The asynchronous operation to execute within the autonomous transaction scope.
    options: TransactionOptions?
    Optional transaction configuration overrides (nested behavior is always forced to `NestedTransactionBehavior.RequireNew`).
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation and containing the computed result.

    Type parameters: TResult: The type of result returned by the operation.

  • methodExecuteAsync<TResult>
    public async Task<TResult> ExecuteAsync<TResult>(Func<ITransactionContext, CancellationToken, Task<TResult>> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes the specified asynchronous function inside an independent autonomous transaction, commits it durably, and returns its result.

    operation: Func<ITransactionContext, CancellationToken, Task<TResult>>
    The asynchronous operation to execute within the autonomous transaction scope.
    options: TransactionOptions?
    Optional transaction configuration overrides (nested behavior is always forced to `NestedTransactionBehavior.RequireNew`).
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation and containing the computed result.

    Type parameters: TResult: The type of result returned by the operation.

class

DeferredTransactionUnitOfWork

Ensamblado: EricksonLopez.Transaction
public sealed class DeferredTransactionUnitOfWork : IDeferredTransactionUnitOfWork, IAsyncDisposable, IDisposable
Implementa: IAsyncDisposable, IDeferredTransactionUnitOfWork, IDisposable

Scoped unit-of-work coordinator for inspecting and explicitly materializing deferred ambient transactions.

Miembros (7)

  • constructorDeferredTransactionUnitOfWork
    public DeferredTransactionUnitOfWork(ITransactionManager transactionManager)

    Initializes a new instance of the `DeferredTransactionUnitOfWork` class.

    transactionManager: ITransactionManager
    The transaction coordinator.

    Exceptions: ArgumentNullException: `transactionManager` is `null`.

  • methodBeginExplicitTransactionAsync
    public Task<ITransaction> BeginExplicitTransactionAsync(TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Explicitly begins a new `ITransaction` scope (for example, inside an `INonAutoTransactionalCommand` handler after external HTTP calls or KDF hashing complete).

    options: TransactionOptions?
    Optional transaction configuration options.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the newly opened `ITransaction`.

  • methodDispose
    public void Dispose()

    Inherits documentation from base type or interface.

  • methodDisposeAsync
    public async ValueTask DisposeAsync()

    Inherits documentation from base type or interface.

  • methodEnsureTransactionAsync
    public async ValueTask<ITransactionContext> EnsureTransactionAsync(CancellationToken cancellationToken = default)

    Materializes the current deferred ambient transaction asynchronously if one is active, or begins a new physical transaction when no ambient scope is active.

    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: The materialized active `ITransactionContext`.

  • propertyCurrentContext
    public ITransactionContext? CurrentContext { get; }

    Gets the current ambient transaction context, or `null` if no ambient scope is active.

  • propertyHasMaterializedTransaction
    public bool HasMaterializedTransaction { get; }

    Gets a value indicating whether an ambient transaction exists and has physically materialized a database connection and transaction.

class

DelegateDbConnectionFactory

Ensamblado: EricksonLopez.Transaction
public sealed class DelegateDbConnectionFactory : IDbConnectionFactory
Implementa: IDbConnectionFactory

Provides a delegate-based implementation of `IDbConnectionFactory` that wraps caller-supplied factory functions.

Notas:

When constructed with a synchronous delegate, the asynchronous path automatically opens the connection if it is not already open. When constructed with an asynchronous delegate, calling `CreateConnection` throws `System.NotSupportedException`.

Miembros (4)

  • constructorDelegateDbConnectionFactory
    public DelegateDbConnectionFactory(Func<CancellationToken, ValueTask<DbConnection>> asyncFactory)

    Initializes a new instance of the `DelegateDbConnectionFactory` class with an asynchronous factory delegate.

    asyncFactory: Func<CancellationToken, ValueTask<DbConnection>>
    The asynchronous connection factory function.

    Exceptions: ArgumentNullException: `asyncFactory` is `null`

  • constructorDelegateDbConnectionFactory
    public DelegateDbConnectionFactory(Func<DbConnection> syncFactory)

    Initializes a new instance of the `DelegateDbConnectionFactory` class with a synchronous factory delegate.

    syncFactory: Func<DbConnection>
    The synchronous connection factory function.

    Exceptions: ArgumentNullException: `syncFactory` is `null`

  • methodCreateConnection
    public DbConnection CreateConnection()

    Creates a new unopened database connection instance.

    Retorna: A new `DbConnection` instance.

    Exceptions: NotSupportedException: Thrown when the factory was configured with an asynchronous delegate

  • methodCreateConnectionAsync
    public ValueTask<DbConnection> CreateConnectionAsync(CancellationToken cancellationToken = default)

    Creates and asynchronously opens a new database connection.

    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains an open `DbConnection`.

interface

IAutonomousTransactionRunner

Ensamblado: EricksonLopez.Transaction.Abstractions
public interface IAutonomousTransactionRunner

Executes critical durability operations (such as authentication lockout counters, security audit entries, and compromised token-family revocations) on an independent autonomous database connection and transaction whose commit survives even if an enclosing ambient transaction rolls back.

Miembros (4)

  • methodExecuteAsync
    Task ExecuteAsync(Func<CancellationToken, Task> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes the specified asynchronous action inside an independent autonomous transaction and commits it durably.

    operation: Func<CancellationToken, Task>
    The asynchronous operation to execute within the autonomous transaction scope.
    options: TransactionOptions?
    Optional transaction configuration overrides (nested behavior is always forced to `NestedTransactionBehavior.RequireNew`).
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

  • methodExecuteAsync
    Task ExecuteAsync(Func<ITransactionContext, CancellationToken, Task> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes the specified asynchronous action receiving the autonomous `ITransactionContext` and commits it durably.

    operation: Func<ITransactionContext, CancellationToken, Task>
    The asynchronous operation receiving the autonomous transaction context.
    options: TransactionOptions?
    Optional transaction configuration overrides (nested behavior is always forced to `NestedTransactionBehavior.RequireNew`).
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

  • methodExecuteAsync<TResult>
    Task<TResult> ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes the specified asynchronous function inside an independent autonomous transaction, commits it durably, and returns its result.

    operation: Func<CancellationToken, Task<TResult>>
    The asynchronous operation to execute within the autonomous transaction scope.
    options: TransactionOptions?
    Optional transaction configuration overrides (nested behavior is always forced to `NestedTransactionBehavior.RequireNew`).
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation and containing the computed result.

    Type parameters: TResult: The type of result returned by the operation.

  • methodExecuteAsync<TResult>
    Task<TResult> ExecuteAsync<TResult>(Func<ITransactionContext, CancellationToken, Task<TResult>> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes the specified asynchronous function receiving the autonomous `ITransactionContext`, commits it durably, and returns its result.

    operation: Func<ITransactionContext, CancellationToken, Task<TResult>>
    The asynchronous operation receiving the autonomous transaction context.
    options: TransactionOptions?
    Optional transaction configuration overrides (nested behavior is always forced to `NestedTransactionBehavior.RequireNew`).
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation and containing the computed result.

    Type parameters: TResult: The type of result returned by the operation.

interface

IDatabaseDialect

Ensamblado: EricksonLopez.Transaction.Abstractions
public interface IDatabaseDialect

Provides an abstraction over database-specific syntax and behaviors.

Miembros (5)

  • methodApplyReadOnlyModeAsync
    Task ApplyReadOnlyModeAsync(DbConnection connection, DbTransaction transaction, CancellationToken cancellationToken = default)

    Applies a read-only transaction mode to the underlying database transaction, if supported.

    connection: DbConnection
    The database connection.
    transaction: DbTransaction
    The database transaction.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

  • methodCanHandle
    bool CanHandle(DbConnection connection)

    Determines whether this dialect can handle the specified connection.

    connection: DbConnection
    The database connection.

    Retorna: `true` if the dialect can handle the connection; otherwise, `false`.

  • methodGetSavepointCreationSql
    string GetSavepointCreationSql(string savepointName)

    Gets the SQL command text to create a savepoint.

    savepointName: string
    The name of the savepoint.

    Retorna: The SQL command text used to create the savepoint.

  • methodGetSavepointReleaseSql
    string? GetSavepointReleaseSql(string savepointName)

    Gets the SQL command text to release a savepoint.

    savepointName: string
    The name of the savepoint.

    Retorna: The SQL command text used to release the savepoint, or `null` if the operation is not supported by the database engine.

  • methodGetSavepointRollbackSql
    string GetSavepointRollbackSql(string savepointName)

    Gets the SQL command text to rollback to a savepoint.

    savepointName: string
    The name of the savepoint.

    Retorna: The SQL command text used to roll back to the specified savepoint.

interface

IDbConnectionFactory

Ensamblado: EricksonLopez.Transaction.Abstractions
public interface IDbConnectionFactory

Defines a factory responsible for creating and opening database connections.

Miembros (2)

  • methodCreateConnection
    DbConnection CreateConnection()

    Creates a new unopened database connection instance.

    Retorna: A new `DbConnection` instance.

    Exceptions: System.NotSupportedException: Synchronous connection creation is not supported by an asynchronous-only factory implementation.

  • methodCreateConnectionAsync
    ValueTask<DbConnection> CreateConnectionAsync(CancellationToken cancellationToken = default)

    Creates and asynchronously opens a new database connection.

    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains an open `DbConnection`.

interface

IDeferredTransactionContext

Ensamblado: EricksonLopez.Transaction.Abstractions
public interface IDeferredTransactionContext : ITransactionContext
Implementa: ITransactionContext

Extends `ITransactionContext` with non-materializing inspection members and explicit asynchronous connection/transaction materialization for lazy transaction acquisition (`TransactionOptions.DeferAcquisition`).

Miembros (4)

  • methodEnsureMaterializedAsync
    ValueTask EnsureMaterializedAsync(CancellationToken cancellationToken = default)

    Asynchronously opens the underlying physical database connection, begins the database transaction, and invokes any registered `ITransactionLifecycleInterceptor` instances if not already materialized.

    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A value task representing the asynchronous materialization operation.

  • propertyActiveConnection
    DbConnection? ActiveConnection { get; }

    Gets the underlying materialized `DbConnection` if already opened, or `null` while deferred. Accessing this property never triggers connection acquisition.

  • propertyActiveTransaction
    DbTransaction? ActiveTransaction { get; }

    Gets the underlying materialized `DbTransaction` if already started, or `null` while deferred. Accessing this property never triggers connection acquisition.

  • propertyIsMaterialized
    bool IsMaterialized { get; }

    Gets a value indicating whether the underlying physical `DbConnection` and `DbTransaction` have been opened and started. Accessing this property never triggers connection acquisition.

interface

IDeferredTransactionUnitOfWork

Ensamblado: EricksonLopez.Transaction.Abstractions
public interface IDeferredTransactionUnitOfWork

Provides explicit control over deferred unit-of-work transaction materialization so handlers can complete external I/O or CPU-intensive pre-flight work before checking out a pooled database connection.

Miembros (4)

  • methodBeginExplicitTransactionAsync
    Task<ITransaction> BeginExplicitTransactionAsync(TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Explicitly begins a new `ITransaction` scope (for example, inside an `INonAutoTransactionalCommand` handler after external HTTP calls or KDF hashing complete).

    options: TransactionOptions?
    Optional transaction configuration options.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the newly opened `ITransaction`.

  • methodEnsureTransactionAsync
    ValueTask<ITransactionContext> EnsureTransactionAsync(CancellationToken cancellationToken = default)

    Materializes the current deferred ambient transaction asynchronously if one is active, or begins a new physical transaction when no ambient scope is active.

    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: The materialized active `ITransactionContext`.

  • propertyCurrentContext
    ITransactionContext? CurrentContext { get; }

    Gets the current ambient transaction context, or `null` if no ambient scope is active.

  • propertyHasMaterializedTransaction
    bool HasMaterializedTransaction { get; }

    Gets a value indicating whether an ambient transaction exists and has physically materialized a database connection and transaction.

interface

ISavepoint

Ensamblado: EricksonLopez.Transaction.Abstractions
public interface ISavepoint : IAsyncDisposable
Implementa: IAsyncDisposable

Represents a named savepoint within an active transaction, enabling partial rollback without aborting the outer transaction.

Miembros (3)

  • methodReleaseAsync
    Task ReleaseAsync(CancellationToken cancellationToken = default)

    Releases the savepoint in engines that support savepoint destruction.

    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous release operation.

  • methodRollbackAsync
    Task RollbackAsync(CancellationToken cancellationToken = default)

    Rolls back all operations executed within the transaction since this savepoint was created.

    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous rollback operation.

  • propertyName
    string Name { get; }

    Gets the unique identifier or name of the savepoint.

interface

ITransaction

Ensamblado: EricksonLopez.Transaction.Abstractions
public interface ITransaction : IAsyncDisposable
Implementa: IAsyncDisposable

Represents an explicit handle to an active database transaction lifecycle.

Notas:

Consumers should always manage instances of this interface within an `await using` block. If `CommitAsync` is not called before disposal, the transaction is automatically rolled back.

Miembros (6)

  • methodCommitAsync
    Task CommitAsync(CancellationToken cancellationToken = default)

    Commits the active transaction and persists all changes atomically to storage.

    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous commit operation.

  • methodCreateSavepointAsync
    Task<ISavepoint> CreateSavepointAsync(string name, CancellationToken cancellationToken = default)

    Creates a named savepoint within this transaction.

    name: string
    The unique name that identifies the savepoint within the transaction.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task that represents the asynchronous operation. The task result contains the created `ISavepoint`.

  • methodRollbackAsync
    Task RollbackAsync(CancellationToken cancellationToken = default)

    Rolls back the active transaction and discards all uncommitted modifications.

    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous rollback operation.

  • propertyContext
    ITransactionContext Context { get; }

    Gets the execution context associated with this transaction.

  • propertyState
    TransactionState State { get; }

    Gets the current state of the transaction.

  • propertyTransactionId
    Guid TransactionId { get; }

    Gets the unique identifier of the transaction.

interface

ITransactionContext

Ensamblado: EricksonLopez.Transaction.Abstractions
public interface ITransactionContext : IAsyncDisposable
Implementa: IAsyncDisposable

Provides access to the active database connection, transaction primitive, state, and savepoints during transactional execution.

Notas:

Repositories and persistence adapters receive this context to execute atomic SQL operations without needing to manage transaction lifecycle directly.

Miembros (11)

  • methodCreateSavepointAsync
    Task<ISavepoint> CreateSavepointAsync(string name, CancellationToken cancellationToken = default)

    Creates a named savepoint within this transaction for partial rollback.

    name: string
    The unique name for the savepoint.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the created `ISavepoint`.

  • methodEnlist
    void Enlist(ITransactionEnlistment enlistment)

    Enlists a participant in the lifecycle notifications of this transaction.

    enlistment: ITransactionEnlistment
    The enlistment participant to register.
  • methodSetRollbackOnly
    void SetRollbackOnly(string reason)

    Marks this transaction context as rollback-only, preventing subsequent commits.

    reason: string
    The diagnostic reason for marking the transaction rollback-only.
  • propertyCancellationToken
    CancellationToken CancellationToken { get; }

    Gets the cancellation token scoped to this transaction execution.

  • propertyConnection
    DbConnection Connection { get; }

    Gets the underlying active database connection associated with this transaction.

    Do not manually invoke `Dispose()`, `DbConnection.Close()`, or `DbConnection.BeginTransaction()` on this instance. Mutating the connection state manually circumvents the state machine and corrupts the transaction boundary.

  • propertyEnlistments
    IReadOnlyList<ITransactionEnlistment> Enlistments { get; }

    Gets the read-only collection of enlistments attached to this transaction lifecycle.

  • propertyIsRollbackOnly
    bool IsRollbackOnly { get; }

    Gets a value indicating whether this transaction context has been marked rollback-only.

  • propertyIsolationLevel
    TransactionIsolationLevel IsolationLevel { get; }

    Gets the isolation level configured for this transaction.

  • propertyState
    TransactionState State { get; }

    Gets the current lifecycle state of the transaction.

  • propertyTransaction
    DbTransaction Transaction { get; }

    Gets the underlying active database transaction.

  • propertyTransactionId
    Guid TransactionId { get; }

    Gets the unique identifier of this transaction execution context.

interface

ITransactionEnlistment

Ensamblado: EricksonLopez.Transaction.Abstractions
public interface ITransactionEnlistment

Defines lifecycle hooks for participants enlisting in a transaction boundary.

Miembros (4)

  • methodAfterCommitAsync
    Task AfterCommitAsync(ITransactionContext context, CancellationToken cancellationToken = default)

    Executes immediately after the physical database transaction has committed successfully.

    context: ITransactionContext
    The committed transaction context.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

  • methodAfterRollbackAsync
    Task AfterRollbackAsync(ITransactionContext context, CancellationToken cancellationToken = default)

    Executes after the transaction has been rolled back.

    context: ITransactionContext
    The rolled-back transaction context.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

  • methodBeforeCommitAsync
    Task BeforeCommitAsync(ITransactionContext context, CancellationToken cancellationToken = default)

    Executes immediately prior to committing the physical database transaction.

    context: ITransactionContext
    The active transaction context.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

  • methodOnExceptionAsync
    Task OnExceptionAsync(ITransactionContext context, Exception exception, CancellationToken cancellationToken = default)

    Executes when an exception occurs during the execution of the transaction or its commit phase.

    context: ITransactionContext
    The active transaction context.
    exception: Exception
    The exception that occurred.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

interface

ITransactionLifecycleInterceptor

Ensamblado: EricksonLopez.Transaction.Abstractions
public interface ITransactionLifecycleInterceptor

Defines a lifecycle interceptor invoked immediately after a physical database transaction is opened (for example, to configure transaction-scoped PostgreSQL RLS session variables via `set_config(..., true)`).

Miembros (1)

  • methodOnTransactionOpenedAsync
    Task OnTransactionOpenedAsync(ITransactionContext context, CancellationToken cancellationToken = default)

    Invoked immediately after a physical database transaction is opened and before user operations execute.

    context: ITransactionContext
    The active transaction context containing the connection and transaction.
    cancellationToken: CancellationToken
    A token to monitor for cancellation requests.

    Retorna: A task representing the asynchronous initialization operation.

interface

ITransactionManager

Ensamblado: EricksonLopez.Transaction.Abstractions
public interface ITransactionManager

Defines the primary coordinator for creating, executing, and orchestrating database transaction boundaries.

Miembros (6)

  • methodBeginAsync
    Task<ITransaction> BeginAsync(TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Begins a new transaction explicitly with the specified options.

    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains an `ITransaction` lifecycle handle.

  • methodExecuteAsync
    Task ExecuteAsync(Func<ITransactionContext, Task> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a delegate within an automatic transaction boundary, committing on success and rolling back on failure.

    operation: Func<ITransactionContext, Task>
    The asynchronous transactional operation to execute.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

    Exceptions: ArgumentNullException: `operation` is `null`; InvalidOperationException: `options` specifies `NestedTransactionBehavior.Suppress`. A context-receiving operation cannot run inside a suppressed transaction scope because no ambient `ITransactionContext` is available. Use the parameterless `ExecuteAsync(Func<Task>, TransactionOptions, CancellationToken)` overload instead; Exceptions.TransactionTimeoutException: The operation exceeded the configured `TransactionOptions.Timeout`.

  • methodExecuteAsync
    Task ExecuteAsync(Func<Task> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a parameterless delegate within an automatic transaction boundary, committing on success and rolling back on failure.

    operation: Func<Task>
    The asynchronous operation to execute.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

    Exceptions: ArgumentNullException: `operation` is `null`; Exceptions.TransactionTimeoutException: The operation exceeded the configured `TransactionOptions.Timeout`.

  • methodExecuteAsync<TResult>
    Task<TResult> ExecuteAsync<TResult>(Func<ITransactionContext, Task<TResult>> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a delegate within an automatic transaction boundary, returning the computed result on successful commit and rolling back on failure.

    operation: Func<ITransactionContext, Task<TResult>>
    The asynchronous transactional operation to execute.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the value produced by the operation.

    Type parameters: TResult: The type of the value returned by the transactional operation. Exceptions: ArgumentNullException: `operation` is `null`; InvalidOperationException: `options` specifies `NestedTransactionBehavior.Suppress`. A context-receiving operation cannot run inside a suppressed transaction scope because no ambient `ITransactionContext` is available. Use the parameterless `ExecuteAsync<TResult>(Func<Task<TResult>>, TransactionOptions, CancellationToken)` overload instead; Exceptions.TransactionTimeoutException: The operation exceeded the configured `TransactionOptions.Timeout`.

  • methodExecuteAsync<TResult>
    Task<TResult> ExecuteAsync<TResult>(Func<Task<TResult>> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a parameterless delegate within an automatic transaction boundary, returning the computed result on successful commit and rolling back on failure.

    operation: Func<Task<TResult>>
    The asynchronous operation to execute.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the value produced by the operation.

    Type parameters: TResult: The type of the value returned by the transactional operation. Exceptions: ArgumentNullException: `operation` is `null`; Exceptions.TransactionTimeoutException: The operation exceeded the configured `TransactionOptions.Timeout`.

  • propertyCurrentContext
    ITransactionContext? CurrentContext { get; }

    Gets the ambient transaction context active on the current asynchronous flow, or `null` if no transaction is active.

    Returns `null` both when no transaction has been started and when the current execution is inside a `NestedTransactionBehavior.Suppress` scope. In the suppressed case, an outer transaction may exist on the calling flow, but its context is intentionally hidden from the suppressed execution to prevent ambient context pollution.

enum

NestedTransactionBehavior

Ensamblado: EricksonLopez.Transaction.Abstractions
public enum NestedTransactionBehavior

Specifies how a transaction coordinator handles nested execution scopes when an ambient transaction is already active.

Miembros (4)

  • fieldJoinExisting
    JoinExisting = 3

    Joins the existing active transaction without creating savepoints, causing any failure to invalidate the entire transaction.

  • fieldRequireNew
    RequireNew = 1

    Requires an independent physical transaction on a separate database connection, suspending any ambient transaction.

  • fieldSuppress
    Suppress = 2

    Executes the nested scope non-transactionally without ambient transaction enlistment.

  • fieldUseSavepoint
    UseSavepoint = 0

    Creates a named savepoint when an active transaction exists, rolling back only the nested scope on failure.

enum

TransactionIsolationLevel

Ensamblado: EricksonLopez.Transaction.Abstractions
public enum TransactionIsolationLevel

Specifies the transaction locking behavior and isolation level for database operations.

Notas:

Choosing an appropriate isolation level is a trade-off between concurrency throughput and anomaly prevention: **Isolation Level**: Phenomena Prevented & Operational Characteristics - **`ReadUncommitted`**: Allows dirty reads, non-repeatable reads, and phantom reads. Lowest locking overhead, zero consistency guarantees. - **`ReadCommitted`**: Prevents dirty reads. Default in PostgreSQL and SQL Server. Susceptible to non-repeatable reads and phantoms. - **`RepeatableRead`**: Prevents dirty reads and non-repeatable reads. In PostgreSQL, also prevents phantom reads via MVCC snapshotting. - **`Serializable`**: Strict serializable execution. Prevents all anomalies including write skew. Throws serialization failures (PostgreSQL SQLSTATE 40001) under conflict. - **`Snapshot`**: Provides snapshot isolation using row versioning without blocking concurrent readers and writers.

Miembros (6)

  • fieldReadCommitted
    ReadCommitted = 2

    Specifies that shared locks are held while data is read to avoid dirty reads, but data can be modified before commit.

  • fieldReadUncommitted
    ReadUncommitted = 1

    Specifies that dirty reads are possible, meaning no shared locks are issued and no exclusive locks are honored.

  • fieldRepeatableRead
    RepeatableRead = 3

    Specifies that locks are placed on all queried data, preventing other concurrent transactions from updating rows.

  • fieldSerializable
    Serializable = 4

    Specifies that range locks are placed on the dataset, preventing other transactions from updating or inserting rows.

  • fieldSnapshot
    Snapshot = 5

    Specifies snapshot isolation using row versioning, reducing blocking between concurrent readers and writers.

  • fieldUnspecified
    Unspecified = 0

    Specifies that an undetermined isolation level different from explicit levels is used.

class

TransactionManager

Ensamblado: EricksonLopez.Transaction
public sealed partial class TransactionManager : ITransactionManager
Implementa: ITransactionManager

Provides transaction coordination, ambient context propagation, and savepoint management.

Miembros (7)

  • constructorTransactionManager
    public TransactionManager(IDbConnectionFactory connectionFactory, ILogger<TransactionManager>? logger = null, IEnumerable<IDatabaseDialect>? dialects = null, IEnumerable<ITransactionLifecycleInterceptor>? lifecycleInterceptors = null)

    Initializes a new instance of the `TransactionManager` class with the specified connection factory.

    connectionFactory: IDbConnectionFactory
    The database connection factory used to create database connections.
    logger: ILogger<TransactionManager>?
    An optional logger instance for diagnostic reporting.
    dialects: IEnumerable<IDatabaseDialect>?
    An optional collection of database dialects to use for provider-specific SQL generation.
    lifecycleInterceptors: IEnumerable<ITransactionLifecycleInterceptor>?
    An optional collection of lifecycle interceptors invoked when physical transactions open.

    Exceptions: ArgumentNullException: `connectionFactory` is `null`

  • methodBeginAsync
    public Task<ITransaction> BeginAsync(TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Begins a new transaction explicitly with the specified options.

    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains an `ITransaction` lifecycle handle.

  • methodExecuteAsync
    public async Task ExecuteAsync(Func<ITransactionContext, Task> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a delegate within an automatic transaction boundary, committing on success and rolling back on failure.

    operation: Func<ITransactionContext, Task>
    The asynchronous transactional operation to execute.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

    Exceptions: ArgumentNullException: `operation` is `null`; InvalidOperationException: `options` specifies `NestedTransactionBehavior.Suppress`. A context-receiving operation cannot run inside a suppressed transaction scope because no ambient `ITransactionContext` is available. Use the parameterless `ExecuteAsync(Func<Task>, TransactionOptions, CancellationToken)` overload instead; Exceptions.TransactionTimeoutException: The operation exceeded the configured `TransactionOptions.Timeout`.

  • methodExecuteAsync
    public async Task ExecuteAsync(Func<Task> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a delegate within an automatic transaction boundary, committing on success and rolling back on failure.

    operation: Func<Task>
    The asynchronous transactional operation to execute.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

    Exceptions: ArgumentNullException: `operation` is `null`; InvalidOperationException: `options` specifies `NestedTransactionBehavior.Suppress`. A context-receiving operation cannot run inside a suppressed transaction scope because no ambient `ITransactionContext` is available. Use the parameterless `ExecuteAsync(Func<Task>, TransactionOptions, CancellationToken)` overload instead; Exceptions.TransactionTimeoutException: The operation exceeded the configured `TransactionOptions.Timeout`.

  • methodExecuteAsync<TResult>
    public async Task<TResult> ExecuteAsync<TResult>(Func<ITransactionContext, Task<TResult>> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a delegate within an automatic transaction boundary, returning the computed result on successful commit and rolling back on failure.

    operation: Func<ITransactionContext, Task<TResult>>
    The asynchronous transactional operation to execute.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the value produced by the operation.

    Type parameters: TResult: The type of the value returned by the transactional operation. Exceptions: ArgumentNullException: `operation` is `null`; InvalidOperationException: `options` specifies `NestedTransactionBehavior.Suppress`. A context-receiving operation cannot run inside a suppressed transaction scope because no ambient `ITransactionContext` is available. Use the parameterless `ExecuteAsync<TResult>(Func<Task<TResult>>, TransactionOptions, CancellationToken)` overload instead; Exceptions.TransactionTimeoutException: The operation exceeded the configured `TransactionOptions.Timeout`.

  • methodExecuteAsync<TResult>
    public async Task<TResult> ExecuteAsync<TResult>(Func<Task<TResult>> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a delegate within an automatic transaction boundary, returning the computed result on successful commit and rolling back on failure.

    operation: Func<Task<TResult>>
    The asynchronous transactional operation to execute.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the value produced by the operation.

    Type parameters: TResult: The type of the value returned by the transactional operation. Exceptions: ArgumentNullException: `operation` is `null`; InvalidOperationException: `options` specifies `NestedTransactionBehavior.Suppress`. A context-receiving operation cannot run inside a suppressed transaction scope because no ambient `ITransactionContext` is available. Use the parameterless `ExecuteAsync<TResult>(Func<Task<TResult>>, TransactionOptions, CancellationToken)` overload instead; Exceptions.TransactionTimeoutException: The operation exceeded the configured `TransactionOptions.Timeout`.

  • propertyCurrentContext
    public ITransactionContext? CurrentContext { get; }

    Gets the ambient transaction context active on the current asynchronous flow, or `null` if no transaction is active.

    Returns `null` both when no transaction has been started and when the current execution is inside a `NestedTransactionBehavior.Suppress` scope. In the suppressed case, an outer transaction may exist on the calling flow, but its context is intentionally hidden from the suppressed execution to prevent ambient context pollution.

record

TransactionOptions

Ensamblado: EricksonLopez.Transaction.Abstractions
public sealed record TransactionOptions

Represents immutable configuration options for controlling transaction behavior, isolation level, timeout, and nesting semantics.

Miembros (15)

  • methodWithTimeout
    public static TransactionOptions WithTimeout(TimeSpan timeout)

    Creates a new `TransactionOptions` instance with the specified timeout.

    timeout: TimeSpan
    The transaction execution timeout.

    Retorna: A new `TransactionOptions` instance configured with the specified timeout.

  • propertyAutonomous
    public static TransactionOptions Autonomous { get; }

    Gets a new `TransactionOptions` instance configured to open an independent autonomous connection and transaction (`NestedTransactionBehavior.RequireNew`).

  • propertyCommitOnFailure
    public bool CommitOnFailure { get; init; }

    Gets a value indicating whether pipeline coordinators should commit the transaction even when the command returns a functional failure outcome (provided the transaction was not explicitly marked rollback-only and did not throw an unhandled exception). Defaults to `false`.

  • propertyDeferAcquisition
    public bool DeferAcquisition { get; init; }

    Gets a value indicating whether physical database connection checkout and `BEGIN TRANSACTION` acquisition are deferred until the first database command, savepoint, or explicit materialization call executes. Defaults to `false`.

    Enable this option for workflows that perform slow external HTTP calls (such as breach-password or anti-bot checks) or CPU-intensive cryptographic hashing (such as Argon2id) prior to executing database operations, preventing idle-in-transaction connection pool starvation.

  • propertyDeferred
    public static TransactionOptions Deferred { get; }

    Gets a new `TransactionOptions` instance configured for deferred physical connection and transaction acquisition.

  • propertyIsolationLevel
    public TransactionIsolationLevel IsolationLevel { get; init; }

    Gets the requested isolation level for the transaction.

  • propertyNestedBehavior
    public NestedTransactionBehavior NestedBehavior { get; init; }

    Gets the behavior applied when an execution scope is nested inside an existing transaction.

  • propertyOwnsConnection
    public bool OwnsConnection { get; init; }

    Gets a value indicating whether the transaction manager owns the underlying `Common.DbConnection` and should dispose it when the transaction ends. Defaults to `true`.

    Set this property to `false` when passing an externally managed, consumer-owned connection through `IDbConnectionFactory` whose lifecycle must outlive the individual transaction scope.

  • propertyReadOnly
    public bool ReadOnly { get; init; }

    Gets a value indicating whether the transaction should be opened in read-only mode where supported by the provider.

  • propertyReadOnlyMode
    public static TransactionOptions ReadOnlyMode { get; }

    Gets a new `TransactionOptions` instance configured for read-only execution.

    Each access to this property allocates a new `TransactionOptions` instance. To avoid repeated allocations in hot paths, capture the value in a local variable or a static field.

  • propertySanitizeTelemetryMetadata
    public bool SanitizeTelemetryMetadata { get; init; }

    Gets a value indicating whether sensitive infrastructure metadata should be redacted from OpenTelemetry distributed tracing spans emitted during transaction execution.

    When `true`, the `transaction.id` and `transaction.name` tags are replaced with `[REDACTED]` in all emitted `Diagnostics.Activity` spans. This prevents transaction identifiers and logical names — which may encode PII, business context, or sensitive infrastructure identifiers — from appearing in distributed tracing platforms such as Datadog, Jaeger, or Honeycomb. Enable this option in production environments where tracing data is exported to external observability services. Disable it in local development environments where raw diagnostic data is required for troubleshooting.

  • propertySerializable
    public static TransactionOptions Serializable { get; }

    Gets a new `TransactionOptions` instance configured with `TransactionIsolationLevel.Serializable`.

    Each access to this property allocates a new `TransactionOptions` instance. To avoid repeated allocations in hot paths, capture the value in a local variable or a static field.

  • propertyTimeout
    public TimeSpan? Timeout { get; init; }

    Gets the maximum duration allowed for the transaction before timing out, or `null` for default driver timeout.

  • propertyTransactionName
    public string? TransactionName { get; init; }

    Gets the optional logical name or identifier for the transaction, used in diagnostics and logging.

  • fieldDefault
    public static readonly TransactionOptions Default

    Gets the default transaction options with `TransactionIsolationLevel.ReadCommitted` and `NestedTransactionBehavior.UseSavepoint`.

    This field is a shared singleton. Accessing it incurs no heap allocation. For the most common default transaction configuration, prefer this field over constructing a new instance.

enum

TransactionState

Ensamblado: EricksonLopez.Transaction.Abstractions
public enum TransactionState

Specifies the lifecycle state of a transaction.

Miembros (6)

  • fieldActive
    Active = 1

    Specifies that the transaction is actively executing and accepting operations.

  • fieldCommitted
    Committed = 2

    Specifies that the transaction has successfully committed all modifications to storage.

  • fieldCreated
    Created = 0

    Specifies that the transaction instance has been created but the physical transaction has not yet begun.

  • fieldDisposed
    Disposed = 5

    Specifies that the transaction has completed its lifecycle and released all resources.

  • fieldFailed
    Failed = 4

    Specifies that the transaction encountered an unhandled error or ambiguous failure.

  • fieldRolledBack
    RolledBack = 3

    Specifies that the transaction has rolled back and all modified state was discarded.

EricksonLopez.Transaction.Analyzers#

1
class

ConnectionManipulationAnalyzer

Ensamblado: EricksonLopez.Transaction.Analyzers
public sealed class ConnectionManipulationAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Enforces transaction safety by detecting and preventing direct manipulation of `DbConnection` instances managed by `ITransactionContext`.

Miembros (3)

  • methodInitialize
    public override void Initialize(AnalysisContext context)

    Inherits documentation from base type or interface.

    context: AnalysisContext
  • propertySupportedDiagnostics
    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; }

    Inherits documentation from base type or interface.

  • fieldDiagnosticId
    public const string DiagnosticId

    Specifies the diagnostic identifier for connection manipulation violations.

EricksonLopez.Transaction.Dapper#

1
class

TransactionDapperExtensions

Ensamblado: EricksonLopez.Transaction.Dapper
public static class TransactionDapperExtensions

Provides Dapper extension methods bound directly to an active `ITransactionContext`.

Miembros (10)

  • methodAsCommand
    public static CommandDefinition AsCommand(this ITransactionContext context, string commandText, object? parameters = null, CommandType? commandType = null, CommandFlags flags = CommandFlags.Buffered, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Constructs a `CommandDefinition` configured with the active transaction and cancellation token.

    context: this ITransactionContext
    The active transaction context.
    commandText: string
    The SQL command text to execute.
    parameters: object?
    The command parameters, or `null` if none.
    commandType: CommandType?
    The command type interpretation, or `null` for default.
    flags: CommandFlags
    The behavior flags for command execution.
    commandTimeout: int?
    The per-command timeout in seconds, or `null` to use the default.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A configured `CommandDefinition` bound to the active transaction.

    Exceptions: ArgumentNullException: `context` is `null`; ArgumentException: `commandText` is `null` or whitespace

  • methodExecuteAsync
    public static async Task<int> ExecuteAsync(this ITransactionContext context, string sql, object? param = null, int? commandTimeout = null, CommandType? commandType = null, CancellationToken cancellationToken = default)

    Executes a SQL statement within the active transaction context.

    context: this ITransactionContext
    The active transaction context.
    sql: string
    The SQL statement to execute.
    param: object?
    The parameters to pass to the command, or `null` if none.
    commandTimeout: int?
    The command execution timeout in seconds, or `null` to use the default.
    commandType: CommandType?
    The command type interpretation, or `null` for default.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the number of rows affected.

    Exceptions: ArgumentNullException: `context` is `null`

  • methodExecuteReaderAsync
    public static async Task<IDataReader> ExecuteReaderAsync(this ITransactionContext context, string sql, object? param = null, int? commandTimeout = null, CommandType? commandType = null, CancellationToken cancellationToken = default)

    Executes a query within the active transaction context and returns an `IDataReader`.

    context: this ITransactionContext
    The active transaction context.
    sql: string
    The SQL query to execute.
    param: object?
    The parameters to pass to the query, or `null` if none.
    commandTimeout: int?
    The command execution timeout in seconds, or `null` to use the default.
    commandType: CommandType?
    The command type interpretation, or `null` for default.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the `IDataReader`.

    Exceptions: ArgumentNullException: `context` is `null`

  • methodExecuteScalarAsync<T>
    public static async Task<T?> ExecuteScalarAsync<T>(this ITransactionContext context, string sql, object? param = null, int? commandTimeout = null, CommandType? commandType = null, CancellationToken cancellationToken = default)

    Executes a query within the active transaction context and returns the first column of the first row.

    context: this ITransactionContext
    The active transaction context.
    sql: string
    The SQL query to execute.
    param: object?
    The parameters to pass to the query, or `null` if none.
    commandTimeout: int?
    The command execution timeout in seconds, or `null` to use the default.
    commandType: CommandType?
    The command type interpretation, or `null` for default.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the scalar value, or the default value if the result set is empty.

    Type parameters: T: The type of the scalar value. Exceptions: ArgumentNullException: `context` is `null`

  • methodQueryAsync<T>
    public static async Task<IEnumerable<T>> QueryAsync<T>(this ITransactionContext context, string sql, object? param = null, int? commandTimeout = null, CommandType? commandType = null, CancellationToken cancellationToken = default)

    Executes a query within the active transaction context and returns mapped results.

    context: this ITransactionContext
    The active transaction context.
    sql: string
    The SQL query to execute.
    param: object?
    The parameters to pass to the query, or `null` if none.
    commandTimeout: int?
    The command execution timeout in seconds, or `null` to use the default.
    commandType: CommandType?
    The command type interpretation, or `null` for default.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains an enumerable sequence of mapped entities.

    Type parameters: T: The type of elements in the returned sequence. Exceptions: ArgumentNullException: `context` is `null`

  • methodQueryFirstAsync<T>
    public static async Task<T> QueryFirstAsync<T>(this ITransactionContext context, string sql, object? param = null, int? commandTimeout = null, CommandType? commandType = null, CancellationToken cancellationToken = default)

    Executes a query within the active transaction context and returns the first element.

    context: this ITransactionContext
    The active transaction context.
    sql: string
    The SQL query to execute.
    param: object?
    The parameters to pass to the query, or `null` if none.
    commandTimeout: int?
    The command execution timeout in seconds, or `null` to use the default.
    commandType: CommandType?
    The command type interpretation, or `null` for default.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the first matching element.

    Type parameters: T: The type of the entity to return. Exceptions: ArgumentNullException: `context` is `null`

  • methodQueryFirstOrDefaultAsync<T>
    public static async Task<T?> QueryFirstOrDefaultAsync<T>(this ITransactionContext context, string sql, object? param = null, int? commandTimeout = null, CommandType? commandType = null, CancellationToken cancellationToken = default)

    Executes a query within the active transaction context and returns the first element or a default value.

    context: this ITransactionContext
    The active transaction context.
    sql: string
    The SQL query to execute.
    param: object?
    The parameters to pass to the query, or `null` if none.
    commandTimeout: int?
    The command execution timeout in seconds, or `null` to use the default.
    commandType: CommandType?
    The command type interpretation, or `null` for default.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the first matching element, or the default value if none was found.

    Type parameters: T: The type of the entity to return. Exceptions: ArgumentNullException: `context` is `null`

  • methodQueryMultipleAsync
    public static async Task<SqlMapper.GridReader> QueryMultipleAsync(this ITransactionContext context, string sql, object? param = null, int? commandTimeout = null, CommandType? commandType = null, CancellationToken cancellationToken = default)

    Executes a multiple-result-set query within the active transaction context.

    context: this ITransactionContext
    The active transaction context.
    sql: string
    The SQL query returning multiple result sets to execute.
    param: object?
    The parameters to pass to the query, or `null` if none.
    commandTimeout: int?
    The command execution timeout in seconds, or `null` to use the default.
    commandType: CommandType?
    The command type interpretation, or `null` for default.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a `SqlMapper.GridReader` for reading multiple results.

    Exceptions: ArgumentNullException: `context` is `null`

  • methodQuerySingleAsync<T>
    public static async Task<T> QuerySingleAsync<T>(this ITransactionContext context, string sql, object? param = null, int? commandTimeout = null, CommandType? commandType = null, CancellationToken cancellationToken = default)

    Executes a query within the active transaction context and returns a single element.

    context: this ITransactionContext
    The active transaction context.
    sql: string
    The SQL query to execute.
    param: object?
    The parameters to pass to the query, or `null` if none.
    commandTimeout: int?
    The command execution timeout in seconds, or `null` to use the default.
    commandType: CommandType?
    The command type interpretation, or `null` for default.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the single matching element.

    Type parameters: T: The type of the entity to return. Exceptions: ArgumentNullException: `context` is `null`

  • methodQuerySingleOrDefaultAsync<T>
    public static async Task<T?> QuerySingleOrDefaultAsync<T>(this ITransactionContext context, string sql, object? param = null, int? commandTimeout = null, CommandType? commandType = null, CancellationToken cancellationToken = default)

    Executes a query within the active transaction context and returns a single element or a default value.

    context: this ITransactionContext
    The active transaction context.
    sql: string
    The SQL query to execute.
    param: object?
    The parameters to pass to the query, or `null` if none.
    commandTimeout: int?
    The command execution timeout in seconds, or `null` to use the default.
    commandType: CommandType?
    The command type interpretation, or `null` for default.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the single matching element, or the default value if none was found.

    Type parameters: T: The type of the entity to return. Exceptions: ArgumentNullException: `context` is `null`

EricksonLopez.Transaction.Diagnostics#

1
class

TransactionDiagnostics

Ensamblado: EricksonLopez.Transaction
public static class TransactionDiagnostics

Provides diagnostic, tracing, and metric instruments for transaction monitoring.

Miembros (12)

  • methodRecordCommitted
    public static void RecordCommitted(TransactionIsolationLevel isolationLevel, double durationMs)

    Records a successful transaction commit and its elapsed duration.

    isolationLevel: TransactionIsolationLevel
    The isolation level of the committed transaction.
    durationMs: double
    The total duration of the transaction in milliseconds.
  • methodRecordFailed
    public static void RecordFailed(TransactionIsolationLevel isolationLevel, double durationMs, string? errorType)

    Records a transaction failure, duration, and error type.

    isolationLevel: TransactionIsolationLevel
    The isolation level of the failed transaction.
    durationMs: double
    The total duration of the transaction in milliseconds.
    errorType: string?
    The error type or classification associated with the failure, or `null` if unknown.
  • methodRecordRolledBack
    public static void RecordRolledBack(TransactionIsolationLevel isolationLevel, double durationMs)

    Records a transaction rollback and its elapsed duration.

    isolationLevel: TransactionIsolationLevel
    The isolation level of the rolled-back transaction.
    durationMs: double
    The total duration of the transaction in milliseconds.
  • methodRecordSavepointCreated
    public static void RecordSavepointCreated()

    Records the creation of a savepoint.

  • methodRecordSavepointReleased
    public static void RecordSavepointReleased()

    Records the release of a savepoint.

  • methodRecordSavepointRolledBack
    public static void RecordSavepointRolledBack()

    Records the rollback of a savepoint.

  • methodRecordStarted
    public static void RecordStarted(TransactionIsolationLevel isolationLevel)

    Records the initiation of a transaction with the specified isolation level.

    isolationLevel: TransactionIsolationLevel
    The isolation level of the started transaction.
  • methodStartActivity
    public static Activity? StartActivity(string name, Guid transactionId, TransactionIsolationLevel isolationLevel, string? transactionName = null, bool sanitizeTelemetryMetadata = false)

    Starts a new tracing activity for a transaction.

    name: string
    The operation name for the activity.
    transactionId: Guid
    The unique transaction identifier.
    isolationLevel: TransactionIsolationLevel
    The isolation level of the transaction.
    transactionName: string?
    An optional logical name or purpose assigned to the transaction.
    sanitizeTelemetryMetadata: bool
    When `true`, redacts the `transaction.id` and `transaction.name` tags from the emitted span to prevent personally identifiable information (PII) or sensitive infrastructure identifiers from appearing in distributed tracing platforms (Datadog, Jaeger, Honeycomb, etc.). Corresponds to `TransactionOptions.SanitizeTelemetryMetadata`.

    Retorna: The created `Activity`, or `null` if no listeners are registered.

  • fieldActivitySource
    public static readonly ActivitySource ActivitySource

    Gets the `ActivitySource` for distributed transaction tracing.

  • fieldMeter
    public static readonly Meter Meter

    Gets the `Meter` for transaction rate, duration, and outcome metrics.

  • fieldSourceName
    public const string SourceName

    Specifies the activity source and meter name for OpenTelemetry instrumentation.

  • fieldVersion
    public const string Version

    Specifies the semantic version of the instrumentation schema emitted by this source.

EricksonLopez.Transaction.EntityFrameworkCore#

1
class

DbContextTransactionExtensions

Ensamblado: EricksonLopez.Transaction.EntityFrameworkCore
public static class DbContextTransactionExtensions

Provides extension methods for seamlessly integrating Entity Framework Core with the EricksonLopez.Transaction ecosystem.

Miembros (1)

  • methodUseTransactionAsync
    public static Task UseTransactionAsync(this DbContext dbContext, ITransactionContext transactionContext, CancellationToken cancellationToken = default)

    Enlists the specified `DbContext` into the active transaction managed by `transactionContext`.

    dbContext: this DbContext
    The Entity Framework Core database context.
    transactionContext: ITransactionContext
    The active transaction context.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

    Exceptions: ArgumentNullException: `dbContext` or `transactionContext` is `null`

EricksonLopez.Transaction.Exceptions#

6
class

TransactionCommitException

Ensamblado: EricksonLopez.Transaction.Abstractions
public sealed class TransactionCommitException : TransactionException
Hereda de: TransactionException

Represents an exception thrown when a transaction commit operation fails or when the commit outcome is ambiguous.

Notas:

Architectural Warning (Commit Ambiguity): An exception during commit does not guarantee that the transaction was rolled back. In scenarios involving network drops, TCP connection timeouts, or database server restarts, the database storage engine may have committed the transaction to disk before the acknowledgment packet reached the client application. Applications should rely on distributed idempotency keys and outbox reconciliation rather than assuming uncommitted state upon receiving this error.

Miembros (3)

  • constructorTransactionCommitException
    public TransactionCommitException(string message, Exception innerException, bool isAmbiguous = false)

    Initializes a new instance of the `TransactionCommitException` class with an inner exception.

    message: string
    The error message.
    innerException: Exception
    The underlying exception thrown by the database provider.
    isAmbiguous: bool
    A value indicating whether the commit outcome is uncertain.
  • constructorTransactionCommitException
    public TransactionCommitException(string message, bool isAmbiguous = false)

    Initializes a new instance of the `TransactionCommitException` class.

    message: string
    The error message explaining the commit failure.
    isAmbiguous: bool
    A value indicating whether the commit outcome is uncertain due to network disconnection or timeout.
  • propertyIsAmbiguous
    public bool IsAmbiguous { get; }

    Gets a value indicating whether the final commit status of the transaction is indeterminate.

class

TransactionException

Ensamblado: EricksonLopez.Transaction.Abstractions
public class TransactionException : Exception
Hereda de: Exception

Represents the base exception thrown for transaction management failures.

Miembros (3)

  • constructorTransactionException
    public TransactionException()

    Initializes a new instance of the `TransactionException` class.

  • constructorTransactionException
    public TransactionException(string message)

    Initializes a new instance of the `TransactionException` class with a specified error message.

    message: string
    The message that describes the error.
  • constructorTransactionException
    public TransactionException(string message, Exception innerException)

    Initializes a new instance of the `TransactionException` class with a specified error message and a reference to the inner exception that is the cause of this exception.

    message: string
    The error message that explains the reason for the exception.
    innerException: Exception
    The exception that is the cause of the current exception.
class

TransactionPostCommitException

Ensamblado: EricksonLopez.Transaction.Abstractions
public sealed class TransactionPostCommitException : TransactionException
Hereda de: TransactionException

Represents an exception thrown when the database transaction was committed successfully, but one or more post-commit hooks failed during execution.

Notas:

Architectural Invariant: When this exception is thrown, the underlying physical database transaction has already been committed durably to disk. Application compensation logic must not attempt to rollback the database transaction, as the database state is irrevocably committed.

Miembros (2)

  • constructorTransactionPostCommitException
    public TransactionPostCommitException(string message)

    Initializes a new instance of the `TransactionPostCommitException` class.

    message: string
    The error message.
  • constructorTransactionPostCommitException
    public TransactionPostCommitException(string message, Exception innerException)

    Initializes a new instance of the `TransactionPostCommitException` class with an inner exception.

    message: string
    The error message.
    innerException: Exception
    The exception thrown by post-commit hook execution.
class

TransactionRollbackException

Ensamblado: EricksonLopez.Transaction.Abstractions
public sealed class TransactionRollbackException : TransactionException
Hereda de: TransactionException

Represents an exception thrown when a rollback operation fails explicitly during transaction teardown.

Miembros (2)

  • constructorTransactionRollbackException
    public TransactionRollbackException(string message)

    Initializes a new instance of the `TransactionRollbackException` class with a specified error message.

    message: string
    The message that describes the error.
  • constructorTransactionRollbackException
    public TransactionRollbackException(string message, Exception innerException)

    Initializes a new instance of the `TransactionRollbackException` class with a specified error message and inner exception.

    message: string
    The error message.
    innerException: Exception
    The underlying provider exception during rollback.
class

TransactionStateException

Ensamblado: EricksonLopez.Transaction.Abstractions
public sealed class TransactionStateException : TransactionException
Hereda de: TransactionException

Represents an exception thrown when an operation is attempted on a transaction in an incompatible state.

Miembros (4)

  • constructorTransactionStateException
    public TransactionStateException(string message, Exception innerException)

    Initializes a new instance of the `TransactionStateException` class with a custom message and inner exception.

    message: string
    The descriptive error message.
    innerException: Exception
    The inner exception cause.
  • constructorTransactionStateException
    public TransactionStateException(TransactionState actualState, string attemptedOperation)

    Initializes a new instance of the `TransactionStateException` class.

    actualState: TransactionState
    The current state of the transaction.
    attemptedOperation: string
    The operation that was invalid for the current state.
  • propertyActualState
    public TransactionState ActualState { get; }

    Gets the actual state of the transaction when the violation occurred.

  • propertyAttemptedOperation
    public string? AttemptedOperation { get; }

    Gets the name of the operation that was attempted.

class

TransactionTimeoutException

Ensamblado: EricksonLopez.Transaction.Abstractions
public sealed class TransactionTimeoutException : TransactionException
Hereda de: TransactionException

Represents an exception thrown when a transaction execution duration exceeds its configured timeout threshold.

Miembros (3)

  • constructorTransactionTimeoutException
    public TransactionTimeoutException(string message, Exception innerException, TimeSpan timeout)

    Initializes a new instance of the `TransactionTimeoutException` class with a custom message, inner exception, and timeout.

    message: string
    The descriptive error message.
    innerException: Exception
    The inner exception cause.
    timeout: TimeSpan
    The configured timeout duration.
  • constructorTransactionTimeoutException
    public TransactionTimeoutException(TimeSpan timeout)

    Initializes a new instance of the `TransactionTimeoutException` class with the specified timeout.

    timeout: TimeSpan
    The configured timeout duration that elapsed.
  • propertyTimeout
    public TimeSpan Timeout { get; }

    Gets the timeout duration that was exceeded.

EricksonLopez.Transaction.MariaDb#

2
class

MariaDbConnectionFactory

Ensamblado: EricksonLopez.Transaction.MariaDb
public sealed class MariaDbConnectionFactory : IDbConnectionFactory
Implementa: IDbConnectionFactory

Provides an `IDbConnectionFactory` implementation for MariaDB databases using `MySqlConnection`.

Miembros (3)

  • constructorMariaDbConnectionFactory
    public MariaDbConnectionFactory(string connectionString)

    Initializes a new instance of the `MariaDbConnectionFactory` class with the specified connection string.

    connectionString: string
    The MariaDB database connection string.

    Exceptions: ArgumentException: `connectionString` is `null` or whitespace

  • methodCreateConnection
    public DbConnection CreateConnection()

    Creates a new unopened database connection instance.

    Retorna: A new `DbConnection` instance.

    Exceptions: System.NotSupportedException: Synchronous connection creation is not supported by an asynchronous-only factory implementation.

  • methodCreateConnectionAsync
    public async ValueTask<DbConnection> CreateConnectionAsync(CancellationToken cancellationToken = default)

    Creates and asynchronously opens a new database connection.

    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains an open `DbConnection`.

class

MariaDbErrorClassifier

Ensamblado: EricksonLopez.Transaction.MariaDb
public static class MariaDbErrorClassifier

Provides classification methods for MariaDB error codes, deadlocks, lock wait timeouts, and transient connection failures.

Miembros (3)

  • methodIsDeadlock
    public static bool IsDeadlock(Exception? exception)

    Determines whether the specified exception represents a MariaDB deadlock.

    exception: Exception?
    The exception to inspect, or `null`.

    Retorna: `true` if the exception represents a deadlock; otherwise, `false`.

  • methodIsLockWaitTimeout
    public static bool IsLockWaitTimeout(Exception? exception)

    Determines whether the specified exception represents a MariaDB lock wait timeout.

    exception: Exception?
    The exception to inspect, or `null`.

    Retorna: `true` if the exception represents a lock wait timeout; otherwise, `false`.

  • methodIsTransient
    public static bool IsTransient(Exception? exception)

    Determines whether the specified exception represents a transient failure suitable for retry.

    exception: Exception?
    The exception to inspect, or `null`.

    Retorna: `true` if the exception represents a transient failure; otherwise, `false`.

EricksonLopez.Transaction.Mediator#

11
interface

ICommitOnFailureCommand

Ensamblado: EricksonLopez.Transaction.Mediator
public interface ICommitOnFailureCommand

Marker interface instructing `TransactionPipelineBehavior<TRequest, TResponse>` to commit the ambient transaction even when the handler returns a functional failure outcome (provided the transaction was not marked rollback-only and did not throw an unhandled exception).

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

interface

IConditionalCommitCommand<TResponse>

Ensamblado: EricksonLopez.Transaction.Mediator
public interface IConditionalCommitCommand<TResponse>

Allows a command to evaluate its functional response and decide whether the transaction should commit despite `Result.IsFailure` (for example, committing security revocations on `TOKEN_THEFT_DETECTED` while rolling back on ordinary validation failures).

Notas:

Type parameters: TResponse: The response type returned by the command handler.

Miembros (1)

  • methodShouldCommit
    bool ShouldCommit(TResponse response)

    Determines whether the transaction should be committed for the specified functional failure response.

    response: TResponse
    The response returned by the handler.

    Retorna: `true` to commit the transaction; `false` to roll back.

interface

IDeferredTransactionalCommand

Ensamblado: EricksonLopez.Transaction.Mediator
public interface IDeferredTransactionalCommand

Marker interface instructing `TransactionPipelineBehavior<TRequest, TResponse>` to enable `TransactionOptions.DeferAcquisition` so a physical database connection and `BEGIN TRANSACTION` are acquired lazily only when the first SQL operation executes.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

interface

INonAutoTransactionalCommand

Ensamblado: EricksonLopez.Transaction.Mediator
public interface INonAutoTransactionalCommand : INonTransactionalCommand
Implementa: INonTransactionalCommand

Marker interface for commands that perform external HTTP calls or CPU-heavy cryptographic operations prior to opening an explicit database transaction, opting out of automatic pipeline transaction wrapping.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

interface

INonTransactionalCommand

Ensamblado: EricksonLopez.Transaction.Mediator
public interface INonTransactionalCommand

Marker interface instructing `TransactionPipelineBehavior<TRequest, TResponse>` to bypass automatic transaction creation so the handler can control connection and transaction boundaries explicitly.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

interface

ITransactionalCommand

Ensamblado: EricksonLopez.Transaction.Mediator
public interface ITransactionalCommand

Defines a marker interface indicating that a command request must be executed within an automatic database transaction.

Miembros (0)

Este tipo declara 0 miembros públicos (por ejemplo, interfaz marcadora o enum/record vacío).

interface

ITransactionalCommandOptions

Ensamblado: EricksonLopez.Transaction.Mediator
public interface ITransactionalCommandOptions

Defines the contract for transactional commands that supply custom `TransactionOptions` to `TransactionPipelineBehavior<TRequest, TResponse>` at runtime without requiring reflection.

Notas:

Implementing this interface on a command class is the only functional mechanism for configuring per-command transaction behavior in the pipeline. The `TransactionPipelineBehavior<TRequest, TResponse>` performs a simple cast (`request as ITransactionalCommandOptions`) — no reflection, no attribute inspection. This makes it fully compatible with Native AOT and trimming (`PublishAot=true`). The `TransactionalAttribute` is a related but distinct concept: it is a metadata marker for documentation and tooling purposes and has no runtime effect. Implement this interface instead of (or in addition to) `TransactionalAttribute` to configure actual runtime behavior. Pair with `ITransactionalCommand` for a fully typed, discoverable command contract that communicates both transactional intent (via the interface constraint) and domain semantics.

Miembros (1)

  • propertyTransactionOptions
    TransactionOptions TransactionOptions { get; }

    Gets the transaction options to use when executing this command.

class

TransactionMediatorServiceCollectionExtensions

Ensamblado: EricksonLopez.Transaction.Mediator
public static class TransactionMediatorServiceCollectionExtensions

Provides extension methods for registering transaction pipeline behaviors into Microsoft Dependency Injection.

Miembros (2)

  • methodAddTransactionPipelineBehavior
    public static IServiceCollection AddTransactionPipelineBehavior(this IServiceCollection services)

    Registers the `TransactionPipelineBehavior<TRequest, TResponse>` as an open-generic pipeline behavior.

    services: this IServiceCollection
    The `IServiceCollection` to add services to.

    Retorna: The `IServiceCollection` instance so that additional calls can be chained.

    Exceptions: ArgumentNullException: `services` is `null`

  • methodAddTransactionPipelineBehavior
    public static IServiceCollection AddTransactionPipelineBehavior(this IServiceCollection services, Action<TransactionPipelineOptions> configure)

    Registers the `TransactionPipelineBehavior<TRequest, TResponse>` with custom `TransactionPipelineOptions`.

    services: this IServiceCollection
    The `IServiceCollection` to add services to.
    configure: Action<TransactionPipelineOptions>
    Configuration callback for `TransactionPipelineOptions`.

    Retorna: The `IServiceCollection` instance so that additional calls can be chained.

    Exceptions: ArgumentNullException: `services` or `configure` is `null`

class

TransactionPipelineBehavior<TRequest, TResponse>

Ensamblado: EricksonLopez.Transaction.Mediator
public sealed class TransactionPipelineBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse> where TRequest : notnull
Implementa: IPipelineBehavior<TRequest, TResponse>

Encapsulates mediator command execution within an automatic database transaction boundary, committing on success and rolling back when an unhandled exception is thrown or when a functional failure (`IResultOutcome.IsFailure`) is returned unless configured to commit on failure.

Notas:

Type parameters: TRequest: The type of transactional command request being processed.; TResponse: The type of response returned by the command handler.

Miembros (4)

  • constructorTransactionPipelineBehavior
    public TransactionPipelineBehavior(ITransactionManager transactionManager, IEnumerable<ITransactionEnlistment>? enlistments = null)

    Initializes a new instance of the `TransactionPipelineBehavior<TRequest, TResponse>` class.

    transactionManager: ITransactionManager
    The transaction coordinator instance.
    enlistments: IEnumerable<ITransactionEnlistment>?
    An optional collection of transaction enlistment lifecycle participants.

    Exceptions: ArgumentNullException: `transactionManager` is `null`

  • constructorTransactionPipelineBehavior
    public TransactionPipelineBehavior(ITransactionManager transactionManager, IEnumerable<ITransactionEnlistment>? enlistments, TransactionPipelineOptions? pipelineOptions)

    Initializes a new instance of the `TransactionPipelineBehavior<TRequest, TResponse>` class with optional pipeline configuration.

    transactionManager: ITransactionManager
    The transaction coordinator instance.
    enlistments: IEnumerable<ITransactionEnlistment>?
    An optional collection of transaction enlistment lifecycle participants.
    pipelineOptions: TransactionPipelineOptions?
    Optional global transaction pipeline options.

    Exceptions: ArgumentNullException: `transactionManager` is `null`

  • methodHandle<TNext>
    public async ValueTask<TResponse> Handle<TNext>(TRequest request, TNext next, CancellationToken cancellationToken) where TNext : struct, INext<TResponse>

    Inherits documentation from base type or interface.

    request: TRequest
    next: TNext
    cancellationToken: CancellationToken
  • methodIsTransactionalRequest
    public static bool IsTransactionalRequest(TRequest request)

    Determines whether the specified request participates in an automatic transaction boundary, either via explicit `ITransactionalCommand` or by CQRS `ICommand<TResponse>` convention, unless opted out via `INonTransactionalCommand`.

    request: TRequest
    The mediator request.

    Retorna: `true` if the request is transactional; otherwise, `false`.

class

TransactionPipelineOptions

Ensamblado: EricksonLopez.Transaction.Mediator
public sealed class TransactionPipelineOptions

Configures global pipeline behavior defaults for `TransactionPipelineBehavior<TRequest, TResponse>`.

Miembros (1)

  • propertyDeferAcquisitionByDefault
    public bool DeferAcquisitionByDefault { get; set; }

    Gets or sets a value indicating whether commands without explicit `ITransactionalCommandOptions` defer physical database connection and `BEGIN TRANSACTION` acquisition until first SQL execution. Defaults to `false`.

class

TransactionalAttribute

Ensamblado: EricksonLopez.Transaction.Mediator
public sealed class TransactionalAttribute : Attribute
Hereda de: Attribute

Marks a mediator command with transactional intent, declaring the intended isolation level and timeout for documentation, tooling, and architectural visibility purposes.

Notas:

This attribute is a metadata marker. It communicates intent to developers and tooling, but it does not have a runtime effect on the transaction pipeline by itself. `TransactionPipelineBehavior<TRequest, TResponse>` does not read or process this attribute during execution. To configure transaction options that are functionally applied by the pipeline at runtime, implement `ITransactionalCommandOptions` on the command class. This interface-based approach is also fully compatible with Native AOT and trimming since it requires no reflection. You may use `TransactionalAttribute` alongside `ITransactionalCommandOptions` for documentation clarity — the attribute communicates intent while the interface enforces runtime behavior.

Miembros (4)

  • constructorTransactionalAttribute
    public TransactionalAttribute()

    Initializes a new instance of the `TransactionalAttribute` class.

  • constructorTransactionalAttribute
    public TransactionalAttribute(TransactionIsolationLevel isolationLevel)

    Initializes a new instance of the `TransactionalAttribute` class with the specified isolation level.

    isolationLevel: TransactionIsolationLevel
    The transaction isolation level.
  • propertyIsolationLevel
    public TransactionIsolationLevel IsolationLevel { get; set; }

    Gets or sets the transaction isolation level.

  • propertyTimeoutSeconds
    public int TimeoutSeconds { get; set; }

    Gets or sets the transaction timeout in seconds, where zero indicates the system default timeout.

EricksonLopez.Transaction.MySql#

2
class

MySqlConnectionFactory

Ensamblado: EricksonLopez.Transaction.MySql
public sealed class MySqlConnectionFactory : IDbConnectionFactory
Implementa: IDbConnectionFactory

Provides an `IDbConnectionFactory` implementation for MySQL databases using `MySqlConnection`.

Miembros (3)

  • constructorMySqlConnectionFactory
    public MySqlConnectionFactory(string connectionString)

    Initializes a new instance of the `MySqlConnectionFactory` class with the specified connection string.

    connectionString: string
    The MySQL database connection string.

    Exceptions: ArgumentException: `connectionString` is `null` or whitespace

  • methodCreateConnection
    public DbConnection CreateConnection()

    Creates a new unopened database connection instance.

    Retorna: A new `DbConnection` instance.

    Exceptions: System.NotSupportedException: Synchronous connection creation is not supported by an asynchronous-only factory implementation.

  • methodCreateConnectionAsync
    public async ValueTask<DbConnection> CreateConnectionAsync(CancellationToken cancellationToken = default)

    Creates and asynchronously opens a new database connection.

    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains an open `DbConnection`.

class

MySqlErrorClassifier

Ensamblado: EricksonLopez.Transaction.MySql
public static class MySqlErrorClassifier

Provides classification methods for MySQL error codes, deadlocks, lock wait timeouts, and transient connection failures.

Miembros (3)

  • methodIsDeadlock
    public static bool IsDeadlock(Exception? exception)

    Determines whether the specified exception represents a MySQL deadlock.

    exception: Exception?
    The exception to inspect, or `null`.

    Retorna: `true` if the exception represents a deadlock; otherwise, `false`.

  • methodIsLockWaitTimeout
    public static bool IsLockWaitTimeout(Exception? exception)

    Determines whether the specified exception represents a MySQL lock wait timeout.

    exception: Exception?
    The exception to inspect, or `null`.

    Retorna: `true` if the exception represents a lock wait timeout; otherwise, `false`.

  • methodIsTransient
    public static bool IsTransient(Exception? exception)

    Determines whether the specified exception represents a transient failure suitable for retry.

    exception: Exception?
    The exception to inspect, or `null`.

    Retorna: `true` if the exception represents a transient failure; otherwise, `false`.

EricksonLopez.Transaction.Oracle#

2
class

OracleConnectionFactory

Ensamblado: EricksonLopez.Transaction.Oracle
public sealed class OracleConnectionFactory : IDbConnectionFactory
Implementa: IDbConnectionFactory

Provides an `IDbConnectionFactory` implementation for Oracle databases using `OracleConnection`.

Miembros (3)

  • constructorOracleConnectionFactory
    public OracleConnectionFactory(string connectionString)

    Initializes a new instance of the `OracleConnectionFactory` class with the specified connection string.

    connectionString: string
    The Oracle database connection string.

    Exceptions: ArgumentException: `connectionString` is `null` or whitespace

  • methodCreateConnection
    public DbConnection CreateConnection()

    Creates a new unopened database connection instance.

    Retorna: A new `DbConnection` instance.

    Exceptions: System.NotSupportedException: Synchronous connection creation is not supported by an asynchronous-only factory implementation.

  • methodCreateConnectionAsync
    public async ValueTask<DbConnection> CreateConnectionAsync(CancellationToken cancellationToken = default)

    Creates and asynchronously opens a new database connection.

    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains an open `DbConnection`.

class

OracleErrorClassifier

Ensamblado: EricksonLopez.Transaction.Oracle
public static class OracleErrorClassifier

Provides classification methods for Oracle Database error codes, deadlocks, serialization conflicts, and transient failures.

Miembros (3)

  • methodIsDeadlock
    public static bool IsDeadlock(Exception? exception)

    Determines whether the specified exception represents an Oracle deadlock (ORA-00060).

    exception: Exception?
    The exception to inspect, or `null`.

    Retorna: `true` if the exception represents a deadlock; otherwise, `false`.

  • methodIsSerializationFailure
    public static bool IsSerializationFailure(Exception? exception)

    Determines whether the specified exception represents an Oracle serialization conflict (ORA-08177).

    exception: Exception?
    The exception to inspect, or `null`.

    Retorna: `true` if the exception represents a serialization failure; otherwise, `false`.

  • methodIsTransient
    public static bool IsTransient(Exception? exception)

    Determines whether the specified exception represents a transient failure suitable for retry.

    exception: Exception?
    The exception to inspect, or `null`.

    Retorna: `true` if the exception represents a transient failure; otherwise, `false`.

EricksonLopez.Transaction.PostgreSql#

4
class

PostgreSqlConnectionFactory

Ensamblado: EricksonLopez.Transaction.PostgreSql
public sealed class PostgreSqlConnectionFactory : IDbConnectionFactory, IAsyncDisposable, IDisposable
Implementa: IAsyncDisposable, IDbConnectionFactory, IDisposable

Provides an `IDbConnectionFactory` implementation for PostgreSQL databases using `NpgsqlDataSource`.

Miembros (6)

  • constructorPostgreSqlConnectionFactory
    public PostgreSqlConnectionFactory(NpgsqlDataSource dataSource)

    Initializes a new instance of the `PostgreSqlConnectionFactory` class with an `NpgsqlDataSource`.

    dataSource: NpgsqlDataSource
    The configured PostgreSQL data source.

    Exceptions: ArgumentNullException: `dataSource` is `null`

  • constructorPostgreSqlConnectionFactory
    public PostgreSqlConnectionFactory(string connectionString)

    Initializes a new instance of the `PostgreSqlConnectionFactory` class with a connection string.

    connectionString: string
    The PostgreSQL database connection string.

    Exceptions: ArgumentException: `connectionString` is `null` or whitespace

  • methodCreateConnection
    public DbConnection CreateConnection()

    Creates a new unopened database connection instance.

    Retorna: A new `DbConnection` instance.

    Exceptions: System.NotSupportedException: Synchronous connection creation is not supported by an asynchronous-only factory implementation.

  • methodCreateConnectionAsync
    public async ValueTask<DbConnection> CreateConnectionAsync(CancellationToken cancellationToken = default)

    Creates and asynchronously opens a new database connection.

    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains an open `DbConnection`.

  • methodDispose
    public void Dispose()

    Inherits documentation from base type or interface.

  • methodDisposeAsync
    public async ValueTask DisposeAsync()

    Inherits documentation from base type or interface.

class

PostgreSqlErrorClassifier

Ensamblado: EricksonLopez.Transaction.PostgreSql
public static class PostgreSqlErrorClassifier

Provides classification methods for PostgreSQL error codes, deadlocks, serialization conflicts, and transient failures.

Miembros (12)

  • methodIsDeadlock
    public static bool IsDeadlock(Exception? exception)

    Determines whether the specified exception represents a PostgreSQL deadlock (SQLSTATE 40P01).

    exception: Exception?
    The exception to inspect, or `null`.

    Retorna: `true` if the exception represents a deadlock; otherwise, `false`.

  • methodIsInFailedTransaction
    public static bool IsInFailedTransaction(Exception? exception)

    Determines whether the specified exception indicates that the transaction has entered an aborted state (SQLSTATE 25P02).

    exception: Exception?
    The exception to inspect, or `null`.

    Retorna: `true` if the transaction is in an aborted state; otherwise, `false`.

  • methodIsSerializationFailure
    public static bool IsSerializationFailure(Exception? exception)

    Determines whether the specified exception represents a PostgreSQL serialization conflict (SQLSTATE 40001).

    exception: Exception?
    The exception to inspect, or `null`.

    Retorna: `true` if the exception represents a serialization conflict; otherwise, `false`.

  • methodIsTransient
    public static bool IsTransient(Exception? exception)

    Determines whether the specified exception represents a transient failure suitable for retry.

    exception: Exception?
    The exception to inspect, or `null`.

    Retorna: `true` if the exception represents a transient failure; otherwise, `false`.

  • fieldAdminShutdownSqlState
    public const string AdminShutdownSqlState

    Specifies PostgreSQL SQLSTATE 57P01 (server administrator shutdown).

  • fieldCannotConnectNowSqlState
    public const string CannotConnectNowSqlState

    Specifies PostgreSQL SQLSTATE 57P03 (cannot connect now, server starting up).

  • fieldConnectionFailureSqlState
    public const string ConnectionFailureSqlState

    Specifies PostgreSQL SQLSTATE 08006 (connection failure).

  • fieldCrashShutdownSqlState
    public const string CrashShutdownSqlState

    Specifies PostgreSQL SQLSTATE 57P02 (server crash shutdown).

  • fieldDeadlockDetectedSqlState
    public const string DeadlockDetectedSqlState

    Specifies PostgreSQL SQLSTATE 40P01 (deadlock detected between concurrent transactions).

  • fieldInFailedSqlTransactionSqlState
    public const string InFailedSqlTransactionSqlState

    Specifies PostgreSQL SQLSTATE 25P02 (current transaction is aborted, commands ignored until end of transaction block).

  • fieldQueryCanceledSqlState
    public const string QueryCanceledSqlState

    Specifies PostgreSQL SQLSTATE 57014 (query was canceled by client or statement timeout).

  • fieldSerializationFailureSqlState
    public const string SerializationFailureSqlState

    Specifies PostgreSQL SQLSTATE 40001 (serialization failure under Serializable isolation level).

class

PostgreSqlTransactionManager

Ensamblado: EricksonLopez.Transaction.PostgreSql
public sealed class PostgreSqlTransactionManager : ITransactionManager
Implementa: ITransactionManager

PostgreSQL-specialized `ITransactionManager` coordinator supporting default lazy/deferred connection and transaction acquisition (`PostgreSqlTransactionOptions.DeferAcquisitionByDefault`) and deterministic `ITransactionLifecycleInterceptor` execution upon physical materialization.

Miembros (7)

  • constructorPostgreSqlTransactionManager
    public PostgreSqlTransactionManager(IDbConnectionFactory connectionFactory, PostgreSqlTransactionOptions? options = null, ILogger<TransactionManager>? logger = null, IEnumerable<IDatabaseDialect>? dialects = null, IEnumerable<ITransactionLifecycleInterceptor>? lifecycleInterceptors = null)

    Initializes a new instance of the `PostgreSqlTransactionManager` class.

    connectionFactory: IDbConnectionFactory
    The database connection factory.
    options: PostgreSqlTransactionOptions?
    Optional default PostgreSQL transaction options.
    logger: ILogger<TransactionManager>?
    Optional diagnostic logger.
    dialects: IEnumerable<IDatabaseDialect>?
    Optional registered SQL dialects.
    lifecycleInterceptors: IEnumerable<ITransactionLifecycleInterceptor>?
    Optional lifecycle interceptors invoked when physical transactions open.

    Exceptions: ArgumentNullException: `connectionFactory` is `null`.

  • methodBeginAsync
    public Task<ITransaction> BeginAsync(TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Begins a new transaction explicitly with the specified options.

    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains an `ITransaction` lifecycle handle.

  • methodExecuteAsync
    public Task ExecuteAsync(Func<ITransactionContext, Task> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a delegate within an automatic transaction boundary, committing on success and rolling back on failure.

    operation: Func<ITransactionContext, Task>
    The asynchronous transactional operation to execute.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

    Exceptions: ArgumentNullException: `operation` is `null`; InvalidOperationException: `options` specifies `NestedTransactionBehavior.Suppress`. A context-receiving operation cannot run inside a suppressed transaction scope because no ambient `ITransactionContext` is available. Use the parameterless `ExecuteAsync(Func<Task>, TransactionOptions, CancellationToken)` overload instead; Exceptions.TransactionTimeoutException: The operation exceeded the configured `TransactionOptions.Timeout`.

  • methodExecuteAsync
    public Task ExecuteAsync(Func<Task> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a delegate within an automatic transaction boundary, committing on success and rolling back on failure.

    operation: Func<Task>
    The asynchronous transactional operation to execute.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

    Exceptions: ArgumentNullException: `operation` is `null`; InvalidOperationException: `options` specifies `NestedTransactionBehavior.Suppress`. A context-receiving operation cannot run inside a suppressed transaction scope because no ambient `ITransactionContext` is available. Use the parameterless `ExecuteAsync(Func<Task>, TransactionOptions, CancellationToken)` overload instead; Exceptions.TransactionTimeoutException: The operation exceeded the configured `TransactionOptions.Timeout`.

  • methodExecuteAsync<TResult>
    public Task<TResult> ExecuteAsync<TResult>(Func<ITransactionContext, Task<TResult>> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a delegate within an automatic transaction boundary, returning the computed result on successful commit and rolling back on failure.

    operation: Func<ITransactionContext, Task<TResult>>
    The asynchronous transactional operation to execute.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the value produced by the operation.

    Type parameters: TResult: The type of the value returned by the transactional operation. Exceptions: ArgumentNullException: `operation` is `null`; InvalidOperationException: `options` specifies `NestedTransactionBehavior.Suppress`. A context-receiving operation cannot run inside a suppressed transaction scope because no ambient `ITransactionContext` is available. Use the parameterless `ExecuteAsync<TResult>(Func<Task<TResult>>, TransactionOptions, CancellationToken)` overload instead; Exceptions.TransactionTimeoutException: The operation exceeded the configured `TransactionOptions.Timeout`.

  • methodExecuteAsync<TResult>
    public Task<TResult> ExecuteAsync<TResult>(Func<Task<TResult>> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a delegate within an automatic transaction boundary, returning the computed result on successful commit and rolling back on failure.

    operation: Func<Task<TResult>>
    The asynchronous transactional operation to execute.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the value produced by the operation.

    Type parameters: TResult: The type of the value returned by the transactional operation. Exceptions: ArgumentNullException: `operation` is `null`; InvalidOperationException: `options` specifies `NestedTransactionBehavior.Suppress`. A context-receiving operation cannot run inside a suppressed transaction scope because no ambient `ITransactionContext` is available. Use the parameterless `ExecuteAsync<TResult>(Func<Task<TResult>>, TransactionOptions, CancellationToken)` overload instead; Exceptions.TransactionTimeoutException: The operation exceeded the configured `TransactionOptions.Timeout`.

  • propertyCurrentContext
    public ITransactionContext? CurrentContext { get; }

    Gets the ambient transaction context active on the current asynchronous flow, or `null` if no transaction is active.

    Returns `null` both when no transaction has been started and when the current execution is inside a `NestedTransactionBehavior.Suppress` scope. In the suppressed case, an outer transaction may exist on the calling flow, but its context is intentionally hidden from the suppressed execution to prevent ambient context pollution.

class

PostgreSqlTransactionOptions

Ensamblado: EricksonLopez.Transaction.PostgreSql
public sealed class PostgreSqlTransactionOptions

Configuration options governing default transaction behavior for `PostgreSqlTransactionManager`.

Miembros (3)

  • propertyDefaultIsolationLevel
    public TransactionIsolationLevel DefaultIsolationLevel { get; set; }

    Gets or sets the default PostgreSQL transaction isolation level applied when callers pass `null` options. Defaults to `TransactionIsolationLevel.ReadCommitted`.

  • propertyDefaultTimeout
    public TimeSpan? DefaultTimeout { get; set; }

    Gets or sets the optional default transaction timeout applied when callers pass `null` options.

  • propertyDeferAcquisitionByDefault
    public bool DeferAcquisitionByDefault { get; set; }

    Gets or sets a value indicating whether physical `NpgsqlConnection` checkout and `BEGIN TRANSACTION` acquisition are deferred by default until the first SQL command or savepoint executes. Defaults to `false`.

EricksonLopez.Transaction.Resilience#

1
class

PollyTransactionExtensions

Ensamblado: EricksonLopez.Transaction.Resilience
public static class PollyTransactionExtensions

Provides Polly resilience extensions specifically designed for the transaction ecosystem.

Miembros (2)

  • methodHandleAmbiguousCommit
    public static PolicyBuilder HandleAmbiguousCommit()

    Creates a base policy builder that triggers on ambiguous transaction commit outcomes.

    Retorna: A `PolicyBuilder` configured to handle ambiguous transaction commits.

  • methodHandleAmbiguousCommit
    public static PolicyBuilder HandleAmbiguousCommit(this PolicyBuilder policyBuilder)

    Configures a `PolicyBuilder` to handle ambiguous transaction commit outcomes.

    policyBuilder: this PolicyBuilder
    The base policy builder to configure.

    Retorna: The configured `PolicyBuilder` instance.

    Exceptions: ArgumentNullException: `policyBuilder` is `null`

EricksonLopez.Transaction.Result#

1
class

TransactionResultExtensions

Ensamblado: EricksonLopez.Transaction.Result
public static class TransactionResultExtensions

Provides functional extension methods for `ITransactionManager` integrating with the `ResultInstance` type.

Miembros (4)

  • methodExecuteResultAsync
    public static async Task<ResultInstance> ExecuteResultAsync(this ITransactionManager manager, Func<ITransactionContext, Task<ResultInstance>> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a contextual asynchronous operation returning a `ResultInstance` within an automatic transaction boundary, committing on success and rolling back on failure.

    manager: this ITransactionManager
    The transaction manager.
    operation: Func<ITransactionContext, Task<ResultInstance>>
    The asynchronous operation returning a `ResultInstance`.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the resulting `ResultInstance` produced by the operation.

    Exceptions: ArgumentNullException: `manager` or `operation` is `null`

  • methodExecuteResultAsync
    public static Task<ResultInstance> ExecuteResultAsync(this ITransactionManager manager, Func<Task<ResultInstance>> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a parameterless asynchronous operation returning a `ResultInstance` within an automatic transaction boundary, committing on success and rolling back on failure.

    manager: this ITransactionManager
    The transaction manager.
    operation: Func<Task<ResultInstance>>
    The asynchronous operation returning a `ResultInstance`.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the resulting `ResultInstance` produced by the operation.

    Exceptions: ArgumentNullException: `manager` or `operation` is `null`

  • methodExecuteResultAsync<TValue>
    public static async Task<Result<TValue>> ExecuteResultAsync<TValue>(this ITransactionManager manager, Func<ITransactionContext, Task<Result<TValue>>> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a contextual asynchronous operation returning a value-typed `Result<TValue>` within an automatic transaction boundary, committing on success and rolling back on failure.

    manager: this ITransactionManager
    The transaction manager.
    operation: Func<ITransactionContext, Task<Result<TValue>>>
    The asynchronous operation returning a `Result<TValue>`.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the resulting `Result<TValue>` produced by the operation.

    Type parameters: TValue: The type of the value contained in a successful result. Exceptions: ArgumentNullException: `manager` or `operation` is `null`

  • methodExecuteResultAsync<TValue>
    public static Task<Result<TValue>> ExecuteResultAsync<TValue>(this ITransactionManager manager, Func<Task<Result<TValue>>> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a parameterless asynchronous operation returning a value-typed `Result<TValue>` within an automatic transaction boundary, committing on success and rolling back on failure.

    manager: this ITransactionManager
    The transaction manager.
    operation: Func<Task<Result<TValue>>>
    The asynchronous operation returning a `Result<TValue>`.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the resulting `Result<TValue>` produced by the operation.

    Type parameters: TValue: The type of the value contained in a successful result. Exceptions: ArgumentNullException: `manager` or `operation` is `null`

EricksonLopez.Transaction.SqlServer#

2
class

SqlServerConnectionFactory

Ensamblado: EricksonLopez.Transaction.SqlServer
public sealed class SqlServerConnectionFactory : IDbConnectionFactory
Implementa: IDbConnectionFactory

Provides an `IDbConnectionFactory` implementation for Microsoft SQL Server databases using `SqlConnection`.

Miembros (3)

  • constructorSqlServerConnectionFactory
    public SqlServerConnectionFactory(string connectionString)

    Initializes a new instance of the `SqlServerConnectionFactory` class with the specified connection string.

    connectionString: string
    The SQL Server database connection string.

    Exceptions: ArgumentException: `connectionString` is `null` or whitespace

  • methodCreateConnection
    public DbConnection CreateConnection()

    Creates a new unopened database connection instance.

    Retorna: A new `DbConnection` instance.

    Exceptions: System.NotSupportedException: Synchronous connection creation is not supported by an asynchronous-only factory implementation.

  • methodCreateConnectionAsync
    public async ValueTask<DbConnection> CreateConnectionAsync(CancellationToken cancellationToken = default)

    Creates and asynchronously opens a new database connection.

    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains an open `DbConnection`.

class

SqlServerErrorClassifier

Ensamblado: EricksonLopez.Transaction.SqlServer
public static class SqlServerErrorClassifier

Provides classification methods for Microsoft SQL Server error codes, deadlocks, and serialization conflicts.

Miembros (3)

  • methodIsDeadlock
    public static bool IsDeadlock(Exception? exception)

    Determines whether the specified exception represents a SQL Server deadlock (Error 1205).

    exception: Exception?
    The exception to inspect, or `null`.

    Retorna: `true` if the exception represents a deadlock; otherwise, `false`.

  • methodIsSerializationFailure
    public static bool IsSerializationFailure(Exception? exception)

    Determines whether the specified exception represents a SQL Server snapshot isolation update conflict (Error 3960 or 3961).

    exception: Exception?
    The exception to inspect, or `null`.

    Retorna: `true` if the exception represents a serialization conflict; otherwise, `false`.

  • methodIsTransient
    public static bool IsTransient(Exception? exception)

    Determines whether the specified exception represents a transient failure suitable for retry.

    exception: Exception?
    The exception to inspect, or `null`.

    Retorna: `true` if the exception represents a transient failure; otherwise, `false`.

EricksonLopez.Transaction.Sqlite#

2
class

SqliteConnectionFactory

Ensamblado: EricksonLopez.Transaction.Sqlite
public sealed class SqliteConnectionFactory : IDbConnectionFactory
Implementa: IDbConnectionFactory

Provides an `IDbConnectionFactory` implementation for SQLite databases using `SqliteConnection`.

Miembros (3)

  • constructorSqliteConnectionFactory
    public SqliteConnectionFactory(string connectionString)

    Initializes a new instance of the `SqliteConnectionFactory` class with the specified connection string.

    connectionString: string
    The SQLite database connection string.

    Exceptions: ArgumentException: `connectionString` is `null` or whitespace

  • methodCreateConnection
    public DbConnection CreateConnection()

    Creates a new unopened database connection instance.

    Retorna: A new `DbConnection` instance.

    Exceptions: System.NotSupportedException: Synchronous connection creation is not supported by an asynchronous-only factory implementation.

  • methodCreateConnectionAsync
    public async ValueTask<DbConnection> CreateConnectionAsync(CancellationToken cancellationToken = default)

    Creates and asynchronously opens a new database connection.

    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains an open `DbConnection`.

class

SqliteErrorClassifier

Ensamblado: EricksonLopez.Transaction.Sqlite
public static class SqliteErrorClassifier

Provides classification methods for SQLite error codes, database busy conditions, and lock conflicts.

Miembros (2)

  • methodIsBusyOrLocked
    public static bool IsBusyOrLocked(Exception? exception)

    Determines whether the specified exception represents a SQLite busy or locked condition.

    exception: Exception?
    The exception to inspect, or `null`.

    Retorna: `true` if the exception represents a busy or locked state; otherwise, `false`.

  • methodIsTransient
    public static bool IsTransient(Exception? exception)

    Determines whether the specified exception represents a transient failure suitable for retry.

    exception: Exception?
    The exception to inspect, or `null`.

    Retorna: `true` if the exception represents a transient failure; otherwise, `false`.

EricksonLopez.Transaction.Testing#

4
class

FakeAutonomousTransactionRunner

Ensamblado: EricksonLopez.Transaction.Testing
public sealed class FakeAutonomousTransactionRunner : IAutonomousTransactionRunner
Implementa: IAutonomousTransactionRunner

Provides an in-memory test double for `IAutonomousTransactionRunner` that records every autonomous transaction execution independently of any outer `FakeTransactionManager` rollback.

Miembros (6)

  • constructorFakeAutonomousTransactionRunner
    public FakeAutonomousTransactionRunner(FakeTransactionManager? transactionManager = null)

    Initializes a new instance of the `FakeAutonomousTransactionRunner` class.

    transactionManager: FakeTransactionManager?
    Optional `FakeTransactionManager` whose ambient context is temporarily switched during autonomous execution and restored upon exit.
  • methodExecuteAsync
    public Task ExecuteAsync(Func<CancellationToken, Task> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes the specified asynchronous action inside an independent autonomous transaction and commits it durably.

    operation: Func<CancellationToken, Task>
    The asynchronous operation to execute within the autonomous transaction scope.
    options: TransactionOptions?
    Optional transaction configuration overrides (nested behavior is always forced to `NestedTransactionBehavior.RequireNew`).
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

  • methodExecuteAsync
    public async Task ExecuteAsync(Func<ITransactionContext, CancellationToken, Task> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes the specified asynchronous action inside an independent autonomous transaction and commits it durably.

    operation: Func<ITransactionContext, CancellationToken, Task>
    The asynchronous operation to execute within the autonomous transaction scope.
    options: TransactionOptions?
    Optional transaction configuration overrides (nested behavior is always forced to `NestedTransactionBehavior.RequireNew`).
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

  • methodExecuteAsync<TResult>
    public Task<TResult> ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes the specified asynchronous function inside an independent autonomous transaction, commits it durably, and returns its result.

    operation: Func<CancellationToken, Task<TResult>>
    The asynchronous operation to execute within the autonomous transaction scope.
    options: TransactionOptions?
    Optional transaction configuration overrides (nested behavior is always forced to `NestedTransactionBehavior.RequireNew`).
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation and containing the computed result.

    Type parameters: TResult: The type of result returned by the operation.

  • methodExecuteAsync<TResult>
    public async Task<TResult> ExecuteAsync<TResult>(Func<ITransactionContext, CancellationToken, Task<TResult>> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes the specified asynchronous function inside an independent autonomous transaction, commits it durably, and returns its result.

    operation: Func<ITransactionContext, CancellationToken, Task<TResult>>
    The asynchronous operation to execute within the autonomous transaction scope.
    options: TransactionOptions?
    Optional transaction configuration overrides (nested behavior is always forced to `NestedTransactionBehavior.RequireNew`).
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation and containing the computed result.

    Type parameters: TResult: The type of result returned by the operation.

  • propertyAutonomousTransactions
    public IReadOnlyList<FakeTransaction> AutonomousTransactions { get; }

    Gets the read-only list of autonomous transactions executed through this runner.

class

FakeTransaction

Ensamblado: EricksonLopez.Transaction.Testing
public sealed class FakeTransaction : ITransaction
Implementa: ITransaction

Provides an in-memory test double of `ITransaction` for tracking commit/rollback calls and injecting failures.

Notas:

`CommitCount` and `RollbackCount` enable assertions on how many times each lifecycle operation was invoked. The `ExceptionToThrowOnCommit` and `ExceptionToThrowOnRollback` properties allow tests to simulate provider-level failures. Disposing without committing automatically transitions the context to `TransactionState.RolledBack`.

Miembros (13)

  • constructorFakeTransaction
    public FakeTransaction(FakeTransactionContext? context = null, Action? onDisposed = null)

    Initializes a new instance of the `FakeTransaction` class with an optional test context.

    context: FakeTransactionContext?
    The test transaction context to use, or `null` to create a new context.
    onDisposed: Action?
    An optional callback invoked when the fake transaction is disposed.
  • methodCommitAsync
    public Task CommitAsync(CancellationToken cancellationToken = default)

    Commits the active transaction and persists all changes atomically to storage.

    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous commit operation.

  • methodCreateSavepointAsync
    public Task<ISavepoint> CreateSavepointAsync(string name, CancellationToken cancellationToken = default)

    Creates a named savepoint within this transaction.

    name: string
    The unique name that identifies the savepoint within the transaction.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task that represents the asynchronous operation. The task result contains the created `ISavepoint`.

  • methodDisposeAsync
    public ValueTask DisposeAsync()

    Inherits documentation from base type or interface.

  • methodRollbackAsync
    public Task RollbackAsync(CancellationToken cancellationToken = default)

    Rolls back the active transaction and discards all uncommitted modifications.

    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous rollback operation.

  • propertyCommitCount
    public int CommitCount { get; private set; }

    Gets the number of times `CommitAsync` was invoked.

  • propertyContext
    public ITransactionContext Context { get; }

    Gets the execution context associated with this transaction.

  • propertyExceptionToThrowOnCommit
    public Exception? ExceptionToThrowOnCommit { get; set; }

    Gets or sets the optional exception to throw when `CommitAsync` is called.

  • propertyExceptionToThrowOnRollback
    public Exception? ExceptionToThrowOnRollback { get; set; }

    Gets or sets the optional exception to throw when `RollbackAsync` is called.

  • propertyIsDisposed
    public bool IsDisposed { get; }

    Gets a value indicating whether this transaction has been disposed.

  • propertyRollbackCount
    public int RollbackCount { get; private set; }

    Gets the number of times `RollbackAsync` was invoked.

  • propertyState
    public TransactionState State { get; }

    Gets the current state of the transaction.

  • propertyTransactionId
    public Guid TransactionId { get; }

    Gets the unique identifier of the transaction.

class

FakeTransactionContext

Ensamblado: EricksonLopez.Transaction.Testing
public sealed class FakeTransactionContext : ITransactionContext
Implementa: ITransactionContext

Provides an in-memory test double of `ITransactionContext` for testing transactional components.

Notas:

`Connection` and `Transaction` always throw `System.NotSupportedException`. The `State` property exposes a public setter to allow tests to simulate lifecycle transitions without executing physical database operations.

Miembros (14)

  • constructorFakeTransactionContext
    public FakeTransactionContext(Guid? transactionId = null, TransactionIsolationLevel isolationLevel = TransactionIsolationLevel.ReadCommitted)

    Initializes a new instance of the `FakeTransactionContext` class.

    transactionId: Guid?
    The unique transaction identifier, or `null` to generate a new identifier.
    isolationLevel: TransactionIsolationLevel
    The isolation level for the context.
  • methodCreateSavepointAsync
    public Task<ISavepoint> CreateSavepointAsync(string name, CancellationToken cancellationToken = default)

    Creates a named savepoint within this transaction for partial rollback.

    name: string
    The unique name for the savepoint.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the created `ISavepoint`.

  • methodDisposeAsync
    public ValueTask DisposeAsync()

    Inherits documentation from base type or interface.

  • methodEnlist
    public void Enlist(ITransactionEnlistment enlistment)

    Enlists a participant in the lifecycle notifications of this transaction.

    enlistment: ITransactionEnlistment
    The enlistment participant to register.
  • methodSetRollbackOnly
    public void SetRollbackOnly(string reason)

    Marks this transaction context as rollback-only, preventing subsequent commits.

    reason: string
    The diagnostic reason for marking the transaction rollback-only.
  • propertyCancellationToken
    public CancellationToken CancellationToken { get; init; }

    Gets the cancellation token scoped to this transaction execution.

  • propertyConnection
    public DbConnection Connection { get; }

    Gets the underlying active database connection associated with this transaction.

    Do not manually invoke `Dispose()`, `DbConnection.Close()`, or `DbConnection.BeginTransaction()` on this instance. Mutating the connection state manually circumvents the state machine and corrupts the transaction boundary.

  • propertyCreatedSavepoints
    public IReadOnlyList<string> CreatedSavepoints { get; }

    Gets the read-only collection of savepoint names created within this context.

  • propertyEnlistments
    public IReadOnlyList<ITransactionEnlistment> Enlistments { get; }

    Gets the read-only collection of enlistments attached to this transaction lifecycle.

  • propertyIsRollbackOnly
    public bool IsRollbackOnly { get; set; }

    Gets a value indicating whether this transaction context has been marked rollback-only.

  • propertyIsolationLevel
    public TransactionIsolationLevel IsolationLevel { get; }

    Gets the isolation level configured for this transaction.

  • propertyState
    public TransactionState State { get; set; }

    Gets or sets the current lifecycle state of the transaction.

    The setter is available to allow tests to simulate state transitions programmatically.

  • propertyTransaction
    public DbTransaction Transaction { get; }

    Gets the underlying active database transaction.

  • propertyTransactionId
    public Guid TransactionId { get; }

    Gets the unique identifier of this transaction execution context.

class

FakeTransactionManager

Ensamblado: EricksonLopez.Transaction.Testing
public sealed class FakeTransactionManager : ITransactionManager
Implementa: ITransactionManager

Provides an in-memory test double of `ITransactionManager` for unit and integration testing.

Notas:

All transactions created by this manager are tracked in `StartedTransactions`, enabling assertions on transaction lifecycle behavior. The `ExceptionToThrowOnCommit` property can be used to simulate commit failures.

Miembros (8)

  • methodBeginAsync
    public Task<ITransaction> BeginAsync(TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Begins a new transaction explicitly with the specified options.

    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains an `ITransaction` lifecycle handle.

  • methodExecuteAsync
    public async Task ExecuteAsync(Func<ITransactionContext, Task> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a delegate within an automatic transaction boundary, committing on success and rolling back on failure.

    operation: Func<ITransactionContext, Task>
    The asynchronous transactional operation to execute.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

    Exceptions: ArgumentNullException: `operation` is `null`; InvalidOperationException: `options` specifies `NestedTransactionBehavior.Suppress`. A context-receiving operation cannot run inside a suppressed transaction scope because no ambient `ITransactionContext` is available. Use the parameterless `ExecuteAsync(Func<Task>, TransactionOptions, CancellationToken)` overload instead; Exceptions.TransactionTimeoutException: The operation exceeded the configured `TransactionOptions.Timeout`.

  • methodExecuteAsync
    public async Task ExecuteAsync(Func<Task> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a delegate within an automatic transaction boundary, committing on success and rolling back on failure.

    operation: Func<Task>
    The asynchronous transactional operation to execute.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

    Exceptions: ArgumentNullException: `operation` is `null`; InvalidOperationException: `options` specifies `NestedTransactionBehavior.Suppress`. A context-receiving operation cannot run inside a suppressed transaction scope because no ambient `ITransactionContext` is available. Use the parameterless `ExecuteAsync(Func<Task>, TransactionOptions, CancellationToken)` overload instead; Exceptions.TransactionTimeoutException: The operation exceeded the configured `TransactionOptions.Timeout`.

  • methodExecuteAsync<TResult>
    public async Task<TResult> ExecuteAsync<TResult>(Func<ITransactionContext, Task<TResult>> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a delegate within an automatic transaction boundary, returning the computed result on successful commit and rolling back on failure.

    operation: Func<ITransactionContext, Task<TResult>>
    The asynchronous transactional operation to execute.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the value produced by the operation.

    Type parameters: TResult: The type of the value returned by the transactional operation. Exceptions: ArgumentNullException: `operation` is `null`; InvalidOperationException: `options` specifies `NestedTransactionBehavior.Suppress`. A context-receiving operation cannot run inside a suppressed transaction scope because no ambient `ITransactionContext` is available. Use the parameterless `ExecuteAsync<TResult>(Func<Task<TResult>>, TransactionOptions, CancellationToken)` overload instead; Exceptions.TransactionTimeoutException: The operation exceeded the configured `TransactionOptions.Timeout`.

  • methodExecuteAsync<TResult>
    public async Task<TResult> ExecuteAsync<TResult>(Func<Task<TResult>> operation, TransactionOptions? options = null, CancellationToken cancellationToken = default)

    Executes a delegate within an automatic transaction boundary, returning the computed result on successful commit and rolling back on failure.

    operation: Func<Task<TResult>>
    The asynchronous transactional operation to execute.
    options: TransactionOptions?
    The transaction options controlling isolation level, timeout, and nesting behavior, or `null` to use defaults.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains the value produced by the operation.

    Type parameters: TResult: The type of the value returned by the transactional operation. Exceptions: ArgumentNullException: `operation` is `null`; InvalidOperationException: `options` specifies `NestedTransactionBehavior.Suppress`. A context-receiving operation cannot run inside a suppressed transaction scope because no ambient `ITransactionContext` is available. Use the parameterless `ExecuteAsync<TResult>(Func<Task<TResult>>, TransactionOptions, CancellationToken)` overload instead; Exceptions.TransactionTimeoutException: The operation exceeded the configured `TransactionOptions.Timeout`.

  • propertyCurrentContext
    public ITransactionContext? CurrentContext { get; set; }

    Gets or sets the ambient transaction context active on the current asynchronous flow.

    The setter is available to allow tests to pre-configure or inspect ambient state.

  • propertyExceptionToThrowOnCommit
    public Exception? ExceptionToThrowOnCommit { get; set; }

    Gets or sets an optional exception to throw during commit across created transactions.

  • propertyStartedTransactions
    public IReadOnlyList<FakeTransaction> StartedTransactions { get; }

    Gets the read-only collection of transactions created by this manager.

Microsoft.Extensions.DependencyInjection#

7
class

MariaDbTransactionExtensions

Ensamblado: EricksonLopez.Transaction.MariaDb
public static class MariaDbTransactionExtensions

Provides extension methods for registering MariaDB transaction services into an `IServiceCollection`.

Miembros (1)

  • methodAddMariaDbTransaction
    public static IServiceCollection AddMariaDbTransaction(this IServiceCollection services, string connectionString)

    Registers MariaDB database connection factory and transaction manager services.

    services: this IServiceCollection
    The service collection to add services to.
    connectionString: string
    The MariaDB database connection string.

    Retorna: The service collection for chaining.

    Exceptions: ArgumentNullException: `services` is `null`; ArgumentException: `connectionString` is `null` or whitespace

class

MySqlTransactionExtensions

Ensamblado: EricksonLopez.Transaction.MySql
public static class MySqlTransactionExtensions

Provides extension methods for registering MySQL transaction services into an `IServiceCollection`.

Miembros (1)

  • methodAddMySqlTransaction
    public static IServiceCollection AddMySqlTransaction(this IServiceCollection services, string connectionString)

    Registers MySQL database connection factory and transaction manager services.

    services: this IServiceCollection
    The service collection to add services to.
    connectionString: string
    The MySQL database connection string.

    Retorna: The service collection for chaining.

    Exceptions: ArgumentNullException: `services` is `null`; ArgumentException: `connectionString` is `null` or whitespace

class

OracleTransactionExtensions

Ensamblado: EricksonLopez.Transaction.Oracle
public static class OracleTransactionExtensions

Provides extension methods for registering Oracle transaction services into an `IServiceCollection`.

Miembros (1)

  • methodAddOracleTransaction
    public static IServiceCollection AddOracleTransaction(this IServiceCollection services, string connectionString)

    Registers Oracle database connection factory and transaction manager services.

    services: this IServiceCollection
    The service collection to add services to.
    connectionString: string
    The Oracle database connection string.

    Retorna: The service collection for chaining.

    Exceptions: ArgumentNullException: `services` is `null`; ArgumentException: `connectionString` is `null` or whitespace

class

PostgreSqlTransactionExtensions

Ensamblado: EricksonLopez.Transaction.PostgreSql
public static class PostgreSqlTransactionExtensions

Provides extension methods for registering PostgreSQL transaction services into an `IServiceCollection`.

Miembros (4)

  • methodAddPostgreSqlTransaction
    public static IServiceCollection AddPostgreSqlTransaction(this IServiceCollection services, NpgsqlDataSource dataSource)

    Registers PostgreSQL database connection factory and transaction manager services using an `NpgsqlDataSource`.

    services: this IServiceCollection
    The service collection to add services to.
    dataSource: NpgsqlDataSource
    The configured PostgreSQL data source.

    Retorna: The service collection for chaining.

    Exceptions: ArgumentNullException: `services` or `dataSource` is `null`

  • methodAddPostgreSqlTransaction
    public static IServiceCollection AddPostgreSqlTransaction(this IServiceCollection services, NpgsqlDataSource dataSource, Action<PostgreSqlTransactionOptions>? configure)

    Registers PostgreSQL database connection factory and transaction manager services using an `NpgsqlDataSource` and optional `PostgreSqlTransactionOptions` configuration.

    services: this IServiceCollection
    The service collection to add services to.
    dataSource: NpgsqlDataSource
    The configured PostgreSQL data source.
    configure: Action<PostgreSqlTransactionOptions>?
    Optional configuration callback for `PostgreSqlTransactionOptions`.

    Retorna: The service collection for chaining.

    Exceptions: ArgumentNullException: `services` or `dataSource` is `null`

  • methodAddPostgreSqlTransaction
    public static IServiceCollection AddPostgreSqlTransaction(this IServiceCollection services, string connectionString)

    Registers PostgreSQL database connection factory and transaction manager services using a connection string.

    services: this IServiceCollection
    The service collection to add services to.
    connectionString: string
    The PostgreSQL database connection string.

    Retorna: The service collection for chaining.

    Exceptions: ArgumentNullException: `services` is `null`; ArgumentException: `connectionString` is `null` or whitespace

  • methodAddPostgreSqlTransaction
    public static IServiceCollection AddPostgreSqlTransaction(this IServiceCollection services, string connectionString, Action<PostgreSqlTransactionOptions>? configure)

    Registers PostgreSQL database connection factory and transaction manager services using a connection string and optional `PostgreSqlTransactionOptions` configuration.

    services: this IServiceCollection
    The service collection to add services to.
    connectionString: string
    The PostgreSQL database connection string.
    configure: Action<PostgreSqlTransactionOptions>?
    Optional configuration callback for `PostgreSqlTransactionOptions`.

    Retorna: The service collection for chaining.

    Exceptions: ArgumentNullException: `services` is `null`; ArgumentException: `connectionString` is `null` or whitespace

class

SqlServerTransactionExtensions

Ensamblado: EricksonLopez.Transaction.SqlServer
public static class SqlServerTransactionExtensions

Provides extension methods for registering Microsoft SQL Server transaction services into an `IServiceCollection`.

Miembros (1)

  • methodAddSqlServerTransaction
    public static IServiceCollection AddSqlServerTransaction(this IServiceCollection services, string connectionString)

    Registers Microsoft SQL Server database connection factory and transaction manager services.

    services: this IServiceCollection
    The service collection to add services to.
    connectionString: string
    The SQL Server database connection string.

    Retorna: The service collection for chaining.

    Exceptions: ArgumentNullException: `services` is `null`; ArgumentException: `connectionString` is `null` or whitespace

class

SqliteTransactionExtensions

Ensamblado: EricksonLopez.Transaction.Sqlite
public static class SqliteTransactionExtensions

Provides extension methods for registering SQLite transaction services into an `IServiceCollection`.

Miembros (1)

  • methodAddSqliteTransaction
    public static IServiceCollection AddSqliteTransaction(this IServiceCollection services, string connectionString)

    Registers SQLite database connection factory and transaction manager services.

    services: this IServiceCollection
    The service collection to add services to.
    connectionString: string
    The SQLite database connection string.

    Retorna: The service collection for chaining.

    Exceptions: ArgumentNullException: `services` is `null`; ArgumentException: `connectionString` is `null` or whitespace

class

TransactionServiceCollectionExtensions

Ensamblado: EricksonLopez.Transaction
public static class TransactionServiceCollectionExtensions

Provides extension methods for registering transaction management services into an `IServiceCollection`.

Miembros (4)

  • methodAddTransaction
    public static IServiceCollection AddTransaction(this IServiceCollection services, Func<IServiceProvider, CancellationToken, ValueTask<DbConnection>> connectionProvider)

    Registers transaction coordination services using an asynchronous connection creation delegate.

    services: this IServiceCollection
    The `IServiceCollection` to add services to.
    connectionProvider: Func<IServiceProvider, CancellationToken, ValueTask<DbConnection>>
    An asynchronous delegate used to create and open a database connection.

    Retorna: The `IServiceCollection` instance so that additional calls can be chained.

    Exceptions: ArgumentNullException: `services` or `connectionProvider` is `null`

  • methodAddTransaction
    public static IServiceCollection AddTransaction(this IServiceCollection services, Func<IServiceProvider, DbConnection> connectionProvider)

    Registers transaction coordination services using a synchronous connection creation delegate.

    services: this IServiceCollection
    The `IServiceCollection` to add services to.
    connectionProvider: Func<IServiceProvider, DbConnection>
    A synchronous delegate used to create a database connection.

    Retorna: The `IServiceCollection` instance so that additional calls can be chained.

    Exceptions: ArgumentNullException: `services` or `connectionProvider` is `null`

  • methodAddTransaction
    public static IServiceCollection AddTransaction(this IServiceCollection services, Func<IServiceProvider, IDbConnectionFactory> factoryResolver)

    Registers transaction coordination services using a custom connection factory resolver.

    services: this IServiceCollection
    The `IServiceCollection` to add services to.
    factoryResolver: Func<IServiceProvider, IDbConnectionFactory>
    A delegate used to resolve an `IDbConnectionFactory` instance.

    Retorna: The `IServiceCollection` instance so that additional calls can be chained.

    Exceptions: ArgumentNullException: `services` or `factoryResolver` is `null`

  • methodAddTransaction<TConnectionFactory>
    public static IServiceCollection AddTransaction<TConnectionFactory>(this IServiceCollection services) where TConnectionFactory : class, IDbConnectionFactory

    Registers transaction coordination services using the specified connection factory implementation.

    services: this IServiceCollection
    The `IServiceCollection` to add services to.

    Retorna: The `IServiceCollection` instance so that additional calls can be chained.

    Type parameters: TConnectionFactory: The type of the connection factory to register. Exceptions: ArgumentNullException: `services` is `null`

Buscar en el Ecosistema EricksonLopez.*

Escribe el nombre de una librería, ID de paquete NuGet, tipo .NET o concepto arquitectónico para buscar en el portal.