Referencia Pública de API .NETL3 Persistencia e IntegracionesEstableAOT: Completo

EricksonLopez.DapperExtensions

High-performance, Native AOT-ready Dapper extensions for .NET: Unit of Work, nested savepoints, Polly v8 resilience, Roslyn source generators, and multi-provider bulk operations.

36 namespaces75 tipos271 miembrosGenerado desde XML docs y ensamblados · UTC 2026-12-01

Mostrando 75 de 75 tipos (271 miembros)

EricksonLopez.DapperExtensions#

1
class

SqlEntityAttribute

Ensamblado: EricksonLopez.DapperExtensions
public sealed class SqlEntityAttribute : Attribute
Hereda de: Attribute

Specifies that a partial class is a SQL entity for which the Roslyn incremental source generator emits compile-time, zero-reflection Native AOT hydration methods (`ReadFromDataReader`, `GetMultiMapReaderFactory`, and `MultiMap.IDataReaderMapper<T>`).

Miembros (2)

  • constructorSqlEntityAttribute
    public SqlEntityAttribute()

    Initializes a new instance of the `SqlEntityAttribute` class.

  • propertyTableName
    public string? TableName { get; set; }

    Gets or sets the optional database table name metadata associated with this entity.

EricksonLopez.DapperExtensions.Analyzers#

1
class

NoDynamicDapperAnalyzer

Ensamblado: EricksonLopez.DapperExtensions.Analyzers
public sealed class NoDynamicDapperAnalyzer : DiagnosticAnalyzer
Hereda de: DiagnosticAnalyzer

Roslyn diagnostic analyzer (`EL_DAP001`) banning `dynamic` Dapper materialization (such as `QueryAsync<dynamic>`, `Query<dynamic>`, `QuerySingleAsync<dynamic>`, and untyped non-generic `SqlMapper.Query` / `SqlMapper.QueryAsync` overloads) to preserve compile-time type safety, zero-boxing performance, and Native AOT compatibility.

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

    Diagnostic identifier emitted when a Dapper query materializes `dynamic` rows.

EricksonLopez.DapperExtensions.DependencyInjection#

2
class

DapperExtensionsOptions

Ensamblado: EricksonLopez.DapperExtensions.DependencyInjection
public sealed class DapperExtensionsOptions

Represents configuration options for Dapper extensions services and type handler registrations.

Miembros (2)

  • propertyRegisterStandardTypeHandlers
    public bool RegisterStandardTypeHandlers { get; set; }

    Gets or sets a value indicating whether standard Dapper type handlers (`DateOnly`, `TimeOnly`) are registered in Dapper's global registry automatically.

  • propertyRegisterTransientErrorDetectors
    public bool RegisterTransientErrorDetectors { get; set; }

    Gets or sets a value indicating whether singleton instances of provider-specific `ISqlTransientErrorDetector` services are registered in the dependency injection container.

class

DapperExtensionsServiceCollectionExtensions

Ensamblado: EricksonLopez.DapperExtensions.DependencyInjection
public static class DapperExtensionsServiceCollectionExtensions

Provides extension methods for configuring Dapper extensions services on an `IServiceCollection`.

Miembros (4)

  • methodAddDapperExtensions
    public static IServiceCollection AddDapperExtensions(this IServiceCollection services, Action<DapperExtensionsOptions>? configure = null)

    Adds Dapper extensions services to the specified service collection.

    services: this IServiceCollection
    The service collection to configure.
    configure: Action<DapperExtensionsOptions>?
    An optional action to configure options.

    Retorna: The configured service collection.

    Exceptions: ArgumentNullException: `services` is `null`

  • methodAddDapperResiliencePipelines
    public static IServiceCollection AddDapperResiliencePipelines(this IServiceCollection services)

    Registers shared singleton `Resilience.IResiliencePipeline` instances in the service collection so retry and circuit breaker state is shared across requests.

    services: this IServiceCollection
    The service collection.

    Retorna: The configured service collection.

    Exceptions: ArgumentNullException: `services` is `null`

  • methodAddDapperTransientErrorDetectors
    public static IServiceCollection AddDapperTransientErrorDetectors(this IServiceCollection services)

    Registers provider-specific transient error detector singletons into the service collection both by concrete type and via the `ISqlTransientErrorDetector` abstraction.

    services: this IServiceCollection
    The service collection.

    Retorna: The configured service collection.

    Exceptions: ArgumentNullException: `services` is `null`

  • methodAddDapperTypeHandlers
    public static IServiceCollection AddDapperTypeHandlers(this IServiceCollection services)

    Registers standard Dapper type handlers (`DateOnly` and `TimeOnly`) into Dapper's runtime mapping registry.

    services: this IServiceCollection
    The service collection.

    Retorna: The configured service collection.

    Exceptions: ArgumentNullException: `services` is `null`

EricksonLopez.DapperExtensions.HealthChecks#

3
class

DapperHealthCheck

Ensamblado: EricksonLopez.DapperExtensions.HealthChecks
public sealed class DapperHealthCheck : IHealthCheck
Implementa: IHealthCheck

Provides a database health check that validates connectivity by executing a lightweight query via Dapper.

Miembros (2)

  • constructorDapperHealthCheck
    public DapperHealthCheck(Func<CancellationToken, Task<IDbConnection>> connectionFactory, DapperHealthCheckOptions? options = null, TimeProvider? timeProvider = null)

    Initializes a new instance of the `DapperHealthCheck` class.

    connectionFactory: Func<CancellationToken, Task<IDbConnection>>
    The asynchronous factory that supplies an open or openable database connection.
    options: DapperHealthCheckOptions?
    The optional health check configuration parameters.
    timeProvider: TimeProvider?
    The optional time provider for time virtualization.

    Exceptions: ArgumentNullException: `connectionFactory` is `null`

  • methodCheckHealthAsync
    public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    context: HealthCheckContext
    cancellationToken: CancellationToken
class

DapperHealthCheckOptions

Ensamblado: EricksonLopez.DapperExtensions.HealthChecks
public sealed class DapperHealthCheckOptions

Represents configuration options for database connectivity health checks.

Miembros (3)

  • propertyCommandText
    public string CommandText { get; set; }

    Gets or sets the SQL probe query used to verify database connectivity and readiness. Defaults to `SELECT 1;`.

  • propertyDegradedThreshold
    public TimeSpan DegradedThreshold { get; set; }

    Gets or sets the latency threshold beyond which the database response is flagged as `HealthStatus.Degraded`. Defaults to 500 milliseconds.

  • propertyTimeout
    public TimeSpan Timeout { get; set; }

    Gets or sets the timeout duration for the health check query execution. Defaults to 5 seconds.

class

DapperHealthChecksBuilderExtensions

Ensamblado: EricksonLopez.DapperExtensions.HealthChecks
public static class DapperHealthChecksBuilderExtensions

Provides extension methods for registering Dapper database connectivity health checks on `IHealthChecksBuilder`.

Miembros (7)

  • methodAddDapperHealthCheck
    public static IHealthChecksBuilder AddDapperHealthCheck(this IHealthChecksBuilder builder, string name, Action<DapperHealthCheckOptions>? configure = null, HealthStatus? failureStatus = null, IEnumerable<string>? tags = null)

    Adds a Dapper database connectivity health check that resolves `IDbConnection` from a scoped service provider.

    builder: this IHealthChecksBuilder
    The health checks builder.
    name: string
    The unique health check registration name.
    configure: Action<DapperHealthCheckOptions>?
    The optional action to configure health check options.
    failureStatus: HealthStatus?
    The health status reported upon probe failure. Defaults to `HealthStatus.Unhealthy`.
    tags: IEnumerable<string>?
    The optional tags applied to filter health check executions.

    Retorna: The configured `IHealthChecksBuilder` instance.

    Exceptions: ArgumentNullException: `builder` is `null`; ArgumentException: `name` is empty or whitespace

  • methodAddDapperHealthCheck
    public static IHealthChecksBuilder AddDapperHealthCheck(this IHealthChecksBuilder builder, string name, Func<IServiceProvider, CancellationToken, Task<IDbConnection>> connectionFactory, Action<DapperHealthCheckOptions>? configure = null, HealthStatus? failureStatus = null, IEnumerable<string>? tags = null)

    Adds a Dapper database connectivity health check to the health checks builder.

    builder: this IHealthChecksBuilder
    The health checks builder.
    name: string
    The unique health check registration name.
    connectionFactory: Func<IServiceProvider, CancellationToken, Task<IDbConnection>>
    The factory that resolves an `IDbConnection` given the service provider.
    configure: Action<DapperHealthCheckOptions>?
    The optional action to configure health check options.
    failureStatus: HealthStatus?
    The health status reported upon probe failure. Defaults to `HealthStatus.Unhealthy`.
    tags: IEnumerable<string>?
    The optional tags applied to filter health check executions.

    Retorna: The configured `IHealthChecksBuilder` instance.

    Exceptions: ArgumentNullException: `builder` or `connectionFactory` is `null`; ArgumentException: `name` is empty or whitespace

  • methodAddMySqlDapperHealthCheck
    public static IHealthChecksBuilder AddMySqlDapperHealthCheck(this IHealthChecksBuilder builder, string name, Func<IServiceProvider, CancellationToken, Task<IDbConnection>> connectionFactory, Action<DapperHealthCheckOptions>? configure = null, HealthStatus? failureStatus = null, IEnumerable<string>? tags = null)

    Adds a MySQL or MariaDB database connectivity health check configured with default MySQL settings.

    builder: this IHealthChecksBuilder
    The health checks builder.
    name: string
    The unique health check registration name.
    connectionFactory: Func<IServiceProvider, CancellationToken, Task<IDbConnection>>
    The factory that resolves an `IDbConnection` given the service provider.
    configure: Action<DapperHealthCheckOptions>?
    The optional action to configure health check options.
    failureStatus: HealthStatus?
    The health status reported upon probe failure. Defaults to `HealthStatus.Unhealthy`.
    tags: IEnumerable<string>?
    The optional tags applied to filter health check executions.

    Retorna: The configured `IHealthChecksBuilder` instance.

    Exceptions: ArgumentNullException: `builder` or `connectionFactory` is `null`; ArgumentException: `name` is empty or whitespace

  • methodAddOracleDapperHealthCheck
    public static IHealthChecksBuilder AddOracleDapperHealthCheck(this IHealthChecksBuilder builder, string name, Func<IServiceProvider, CancellationToken, Task<IDbConnection>> connectionFactory, Action<DapperHealthCheckOptions>? configure = null, HealthStatus? failureStatus = null, IEnumerable<string>? tags = null)

    Adds an Oracle Database connectivity health check configured with default Oracle settings.

    builder: this IHealthChecksBuilder
    The health checks builder.
    name: string
    The unique health check registration name.
    connectionFactory: Func<IServiceProvider, CancellationToken, Task<IDbConnection>>
    The factory that resolves an `IDbConnection` given the service provider.
    configure: Action<DapperHealthCheckOptions>?
    The optional action to configure health check options.
    failureStatus: HealthStatus?
    The health status reported upon probe failure. Defaults to `HealthStatus.Unhealthy`.
    tags: IEnumerable<string>?
    The optional tags applied to filter health check executions.

    Retorna: The configured `IHealthChecksBuilder` instance.

    Exceptions: ArgumentNullException: `builder` or `connectionFactory` is `null`; ArgumentException: `name` is empty or whitespace

  • methodAddPostgreSqlDapperHealthCheck
    public static IHealthChecksBuilder AddPostgreSqlDapperHealthCheck(this IHealthChecksBuilder builder, string name, Func<IServiceProvider, CancellationToken, Task<IDbConnection>> connectionFactory, Action<DapperHealthCheckOptions>? configure = null, HealthStatus? failureStatus = null, IEnumerable<string>? tags = null)

    Adds a PostgreSQL database connectivity health check configured with default PostgreSQL settings.

    builder: this IHealthChecksBuilder
    The health checks builder.
    name: string
    The unique health check registration name.
    connectionFactory: Func<IServiceProvider, CancellationToken, Task<IDbConnection>>
    The factory that resolves an `IDbConnection` given the service provider.
    configure: Action<DapperHealthCheckOptions>?
    The optional action to configure health check options.
    failureStatus: HealthStatus?
    The health status reported upon probe failure. Defaults to `HealthStatus.Unhealthy`.
    tags: IEnumerable<string>?
    The optional tags applied to filter health check executions.

    Retorna: The configured `IHealthChecksBuilder` instance.

    Exceptions: ArgumentNullException: `builder` or `connectionFactory` is `null`; ArgumentException: `name` is empty or whitespace

  • methodAddSqlServerDapperHealthCheck
    public static IHealthChecksBuilder AddSqlServerDapperHealthCheck(this IHealthChecksBuilder builder, string name, Func<IServiceProvider, CancellationToken, Task<IDbConnection>> connectionFactory, Action<DapperHealthCheckOptions>? configure = null, HealthStatus? failureStatus = null, IEnumerable<string>? tags = null)

    Adds a Microsoft SQL Server database connectivity health check configured with default SQL Server settings.

    builder: this IHealthChecksBuilder
    The health checks builder.
    name: string
    The unique health check registration name.
    connectionFactory: Func<IServiceProvider, CancellationToken, Task<IDbConnection>>
    The factory that resolves an `IDbConnection` given the service provider.
    configure: Action<DapperHealthCheckOptions>?
    The optional action to configure health check options.
    failureStatus: HealthStatus?
    The health status reported upon probe failure. Defaults to `HealthStatus.Unhealthy`.
    tags: IEnumerable<string>?
    The optional tags applied to filter health check executions.

    Retorna: The configured `IHealthChecksBuilder` instance.

    Exceptions: ArgumentNullException: `builder` or `connectionFactory` is `null`; ArgumentException: `name` is empty or whitespace

  • methodAddSqliteDapperHealthCheck
    public static IHealthChecksBuilder AddSqliteDapperHealthCheck(this IHealthChecksBuilder builder, string name, Func<IServiceProvider, CancellationToken, Task<IDbConnection>> connectionFactory, Action<DapperHealthCheckOptions>? configure = null, HealthStatus? failureStatus = null, IEnumerable<string>? tags = null)

    Adds a SQLite database connectivity health check configured with default SQLite settings.

    builder: this IHealthChecksBuilder
    The health checks builder.
    name: string
    The unique health check registration name.
    connectionFactory: Func<IServiceProvider, CancellationToken, Task<IDbConnection>>
    The factory that resolves an `IDbConnection` given the service provider.
    configure: Action<DapperHealthCheckOptions>?
    The optional action to configure health check options.
    failureStatus: HealthStatus?
    The health status reported upon probe failure. Defaults to `HealthStatus.Unhealthy`.
    tags: IEnumerable<string>?
    The optional tags applied to filter health check executions.

    Retorna: The configured `IHealthChecksBuilder` instance.

    Exceptions: ArgumentNullException: `builder` or `connectionFactory` is `null`; ArgumentException: `name` is empty or whitespace

EricksonLopez.DapperExtensions.MariaDb.Bulk#

3
class

BulkBuilder

Ensamblado: EricksonLopez.DapperExtensions.MariaDb
public static class BulkBuilder

Provides factory methods for creating `BulkBuilder<T>` instances.

Miembros (1)

  • methodFrom<T>
    public static BulkBuilder<T> From<T>(IEnumerable<T> items)

    Begins building a bulk INSERT operation for the specified collection.

    items: IEnumerable<T>
    The collection of entities to insert.

    Retorna: A new `BulkBuilder<T>` instance.

    Type parameters: T: The entity type to bulk-insert. Exceptions: ArgumentNullException: `items` is `null`

class

BulkBuilder<T>

Ensamblado: EricksonLopez.DapperExtensions.MariaDb
public sealed class BulkBuilder<T>

Builds parameterized multi-row INSERT SQL statements and Dapper parameters for bulk operations on MariaDB.

Notas:

MariaDB uses multi-row VALUES syntax: `INSERT INTO `table` (`col1`, `col2`) VALUES (@p0_0, @p0_1), (@p1_0, @p1_1), ...` Type parameters: T: The entity type to bulk-insert.

Miembros (7)

  • methodBatchSize
    public BulkBuilder<T> BatchSize(int maxRowsPerBatch)

    Sets the maximum number of rows per generated SQL batch.

    maxRowsPerBatch: int
    The maximum rows per batch (must be greater than zero).

    Retorna: The current builder instance.

    Exceptions: ArgumentOutOfRangeException: `maxRowsPerBatch` is less than or equal to zero

  • methodBuild
    public (string? Sql, DynamicParameters? Parameters) Build()

    Builds the SQL INSERT statement and a `DynamicParameters` object containing all row values as named parameters. When the total parameter count exceeds `MaxParametersPerStatement`, safe parameter-bounded batches are registered for automatic chunked execution in `BulkExtensions.BulkInsertAsync(IDbConnection, string?, DynamicParameters?, IDbTransaction?, int?, CancellationToken)`.

    Retorna: A tuple containing the generated SQL text and parameter collection, or `(null, null)` if there are no items.

    Exceptions: InvalidOperationException: The destination table name or column mappings have not been configured

  • methodBuildBatches
    public IReadOnlyList<(string Sql, DynamicParameters Parameters)> BuildBatches()

    Builds one or more parameter-bounded SQL INSERT batches so large collections never exceed MariaDB's parameter limit.

    Retorna: A read-only list of SQL and parameter batches.

    Exceptions: InvalidOperationException: The destination table name or column mappings have not been configured

  • methodColumn
    public BulkBuilder<T> Column(string columnName, Func<T, object?> selector)

    Adds a column mapping to the bulk INSERT operation.

    columnName: string
    The column name in the target table.
    selector: Func<T, object?>
    The delegate that extracts the column value from each entity item.

    Retorna: The current builder instance.

    Exceptions: ArgumentException: `columnName` is empty, whitespace, or contains null characters; ArgumentNullException: `selector` is `null`

  • methodTable
    public BulkBuilder<T> Table(string tableName)

    Sets the destination table name for the bulk INSERT operation.

    tableName: string
    The table name (or schema-qualified `schema.table`).

    Retorna: The current builder instance.

    Exceptions: ArgumentException: `tableName` is empty, whitespace, contains null characters, or has invalid schema segments

  • propertyCount
    public int Count { get; }

    Gets the number of items to be inserted.

  • fieldMaxParametersPerStatement
    public const int MaxParametersPerStatement

    Defines the maximum number of SQL parameters permitted in a single MariaDB statement batch (MariaDB prepared statement limit is 65,535).

class

BulkExtensions

Ensamblado: EricksonLopez.DapperExtensions.MariaDb
public static class BulkExtensions

Provides extension methods for bulk INSERT, UPSERT, UPDATE, and DELETE operations on MariaDB connections.

Miembros (5)

  • methodBulkDeleteAsync
    public static Task<int> BulkDeleteAsync(this IDbConnection connection, string? sql, DynamicParameters? parameters, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk DELETE statement using pre-built SQL and parameters.

    connection: this IDbConnection
    The database connection to execute the command on.
    sql: string?
    The bulk DELETE SQL statement.
    parameters: DynamicParameters?
    The parameterized values for the bulk operation.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` is `null`

  • methodBulkInsertAsync
    public static async Task<int> BulkInsertAsync(this IDbConnection connection, string? sql, DynamicParameters? parameters, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk INSERT statement using pre-built SQL and parameters.

    connection: this IDbConnection
    The database connection to execute the command on.
    sql: string?
    The multi-row INSERT SQL statement.
    parameters: DynamicParameters?
    The parameterized values for the bulk insert.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` is `null`

  • methodBulkInsertAsync<T>
    public static async Task<int> BulkInsertAsync<T>(this IDbConnection connection, BulkBuilder<T> builder, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk INSERT statement using a configured `BulkBuilder<T>`, automatically chunking into safe parameter-bounded batches when needed.

    connection: this IDbConnection
    The database connection to execute the command on.
    builder: BulkBuilder<T>
    The configured bulk builder.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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 total number of rows affected across all batches.

    Type parameters: T: The entity type to bulk-insert. Exceptions: ArgumentNullException: `connection` or `builder` is `null`

  • methodBulkUpdateAsync
    public static Task<int> BulkUpdateAsync(this IDbConnection connection, string? sql, DynamicParameters? parameters, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk UPDATE statement using pre-built SQL and parameters.

    connection: this IDbConnection
    The database connection to execute the command on.
    sql: string?
    The bulk UPDATE SQL statement.
    parameters: DynamicParameters?
    The parameterized values for the bulk operation.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` is `null`

  • methodBulkUpsertAsync
    public static Task<int> BulkUpsertAsync(this IDbConnection connection, string? sql, DynamicParameters? parameters, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk INSERT ... ON DUPLICATE KEY UPDATE statement using pre-built SQL and parameters.

    connection: this IDbConnection
    The database connection to execute the command on.
    sql: string?
    The multi-row UPSERT SQL statement.
    parameters: DynamicParameters?
    The parameterized values for the bulk operation.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` is `null`

EricksonLopez.DapperExtensions.MariaDb.Pagination#

1
class

PagedQueryExtensions

Ensamblado: EricksonLopez.DapperExtensions.MariaDb
public static class PagedQueryExtensions

Provides extension methods for executing paginated queries with Dapper on MariaDB databases.

Miembros (3)

  • methodQueryCursorPagedAsync<T>
    public static async Task<ICursorPagedList<T>> QueryCursorPagedAsync<T>(this IDbConnection connection, string sql, string cursorColumn, CursorPaginationParameters parameters, Func<T, string> cursorSelector, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a cursor-based (keyset) paginated query returning a cursor paged list.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The base SQL query without keyset filters or ordering.
    cursorColumn: string
    The column name used as the pagination cursor.
    parameters: CursorPaginationParameters
    The cursor pagination parameters containing page boundaries.
    cursorSelector: Func<T, string>
    The delegate that extracts the cursor value from an entity item.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a cursor paged list of `T` items.

    Type parameters: T: The entity type to map each result row to. Exceptions: ArgumentNullException: `connection` or `cursorSelector` is `null`; ArgumentException: `sql` or `cursorColumn` is empty or whitespace

  • methodQueryPagedAsync<T>
    public static async Task<ICountedPagedList<T>> QueryPagedAsync<T>(this IDbConnection connection, string sql, string countSql, PaginationParameters pagination, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes an offset-based paginated query using separate data and total count SQL statements.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The SQL statement to retrieve page data without pagination clauses.
    countSql: string
    The SQL statement to calculate the total record count.
    pagination: PaginationParameters
    The pagination parameters including page number and page size.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a counted paged list of `T` items.

    Type parameters: T: The entity type to map each result row to. Exceptions: ArgumentNullException: `connection` is `null`; ArgumentException: `sql` or `countSql` is empty or whitespace

  • methodQueryPagedMultipleAsync<T>
    public static async Task<ICountedPagedList<T>> QueryPagedMultipleAsync<T>(this IDbConnection connection, string sql, PaginationParameters pagination, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes an offset-based paginated query using a single multi-result SQL statement.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The SQL query returning two result sets: the page items followed by the total count.
    pagination: PaginationParameters
    The pagination parameters including page number and page size.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a counted paged list of `T` items.

    Type parameters: T: The entity type to map each result row to. Exceptions: ArgumentNullException: `connection` is `null`; ArgumentException: `sql` is empty or whitespace

EricksonLopez.DapperExtensions.MariaDb.Transactions#

1
class

TransactionExtensions

Ensamblado: EricksonLopez.DapperExtensions.MariaDb
public static class TransactionExtensions

Provides extension methods for executing operations within a MariaDB transaction scope.

Miembros (2)

  • methodExecuteInTransactionAsync
    public static async Task ExecuteInTransactionAsync(this DbConnection connection, Func<DbTransaction, Task> operation, CancellationToken cancellationToken = default)

    Executes an asynchronous operation within a newly opened transaction, committing automatically on success and rolling back on failure.

    connection: this DbConnection
    The database connection to execute the transaction on.
    operation: Func<DbTransaction, Task>
    The asynchronous operation to execute within the active transaction.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

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

  • methodExecuteInTransactionAsync<TResult>
    public static async Task<TResult> ExecuteInTransactionAsync<TResult>(this DbConnection connection, Func<DbTransaction, Task<TResult>> operation, CancellationToken cancellationToken = default)

    Executes an asynchronous operation returning a result within a newly opened transaction, committing on success and rolling back on failure.

    connection: this DbConnection
    The database connection to execute the transaction on.
    operation: Func<DbTransaction, Task<TResult>>
    The asynchronous operation returning a result to execute within the active transaction.
    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 returned by `operation`.

    Type parameters: TResult: The type of the result returned by the operation. Exceptions: ArgumentNullException: `connection` or `operation` is `null`

EricksonLopez.DapperExtensions.MariaDb.TypeHandlers#

2
class

JsonTypeHandler<T>

Ensamblado: EricksonLopez.DapperExtensions.MariaDb
public sealed class JsonTypeHandler<T> : SqlMapper.TypeHandler<T>
Hereda de: SqlMapper.TypeHandler<T>

Provides a Dapper type handler for MariaDB JSON columns using System.Text.Json serialization.

Notas:

Type parameters: T: The .NET type to serialize and deserialize.

Miembros (2)

  • methodParse
    public override T? Parse(object value)

    Inherits documentation from base type or interface.

    value: object
  • methodSetValue
    public override void SetValue(IDbDataParameter parameter, T? value)

    Inherits documentation from base type or interface.

    parameter: IDbDataParameter
    value: T?
class

MariaDbTypeHandlerRegistrar

Ensamblado: EricksonLopez.DapperExtensions.MariaDb
public static class MariaDbTypeHandlerRegistrar

Provides convenience registration methods for MariaDB JSON type handlers.

Miembros (1)

  • methodRegisterJsonHandler<T>
    public static void RegisterJsonHandler<T>()

    Registers a JSON type handler for the specified type with Dapper.

    Type parameters: T: The .NET type to map to JSON columns.

EricksonLopez.DapperExtensions.MultiMap#

3
interface

IDataReaderMapper<T>

Ensamblado: EricksonLopez.DapperExtensions
public interface IDataReaderMapper<T>

Defines a Native AOT-compatible, reflection-free mapper that reads a single entity of type `T` from an `IDataReader`.

Notas:

Implementations are typically generated at compile time for types annotated with `SqlEntityAttribute`, enabling zero-reflection data reader hydration suitable for Native AOT environments. Type parameters: T: The entity type to map.

Miembros (2)

  • methodGetMultiMapReaderFactory
    static virtual Func<IDataReader, object>? GetMultiMapReaderFactory()

    Returns a factory delegate that reads an instance of `T` from an `IDataReader`, or `null` if not provided by the implementation.

    Retorna: A reader factory delegate, or `null`.

  • methodMap
    T Map(IDataReader reader)

    Maps the current row of the `reader` to an instance of `T`.

    reader: IDataReader
    The data reader positioned at the row to map.

    Retorna: The mapped instance of `T`.

class

MultiMapBuilder<TReturn>

Ensamblado: EricksonLopez.DapperExtensions
public sealed class MultiMapBuilder<TReturn> where TReturn : class, new()

Provides a fluent builder for configuring and executing multi-mapping queries with Native AOT support.

Notas:

This builder supports any number of mapped entity types. When all entity types are annotated with `[SqlEntity]` and the `EricksonLopez.DapperExtensions.SourceGenerators` package is referenced, the AOT-safe path uses source-generated `IDataReaderMapper<T>` parsers, avoiding all runtime reflection and achieving full Native AOT compatibility. When one or more entity types do not have a source-generated parser, the builder falls back to Dapper's reflection-based `QueryAsync` overload (via the `object[]` types array), which does not impose a fixed maximum on the number of mapped types. This fallback path is not Native AOT safe. Type parameters: TReturn: The root entity type to map.

Miembros (9)

  • methodMap<T>
    public MultiMapBuilder<TReturn> Map<T>(string splitOn, Action<TReturn, T> setter, Func<System.Data.IDataReader, object>? parser = null)

    Registers a mapping from the result set to a related entity of type `T`, using an action to apply the related entity to the root.

    splitOn: string
    The column name that marks the boundary between the root and the related entity in the result set.
    setter: Action<TReturn, T>
    An action that applies the related entity to the root instance.
    parser: Func<System.Data.IDataReader, object>?
    An optional AOT-safe factory that reads an instance of `T` from an `Data.IDataReader`. When `null`, the builder falls back to Dapper's reflection-based mapping.

    Retorna: The current builder instance with the mapping registered.

    Type parameters: T: The type of the related entity to map. Exceptions: ArgumentNullException: `setter` or `splitOn` is `null`; ArgumentException: `splitOn` is empty

  • methodMap<T>
    public MultiMapBuilder<TReturn> Map<T>(string splitOn, Func<TReturn, T, TReturn> combiner, Func<System.Data.IDataReader, object>? parser = null)

    Registers a mapping from the result set to a related entity of type `T`, using a combiner function to merge the related entity into the root.

    splitOn: string
    The column name that marks the boundary between the root and the related entity in the result set.
    combiner: Func<TReturn, T, TReturn>
    A function that receives the root and related entity and returns the updated root.
    parser: Func<System.Data.IDataReader, object>?
    An optional AOT-safe factory that reads an instance of `T` from an `Data.IDataReader`. When `null`, the builder falls back to Dapper's reflection-based mapping.

    Retorna: The current builder instance with the mapping registered.

    Type parameters: T: The type of the related entity to map. Exceptions: ArgumentNullException: `splitOn` or `combiner` is `null`; ArgumentException: `splitOn` is empty

  • methodQuery
    public static MultiMapBuilder<TReturn> Query(ISqlQuery query)

    Creates a new `MultiMapBuilder<TReturn>` for the specified SQL query.

    query: ISqlQuery
    The SQL query whose results will be multi-mapped.

    Retorna: A new `MultiMapBuilder<TReturn>` instance bound to the query.

    Exceptions: ArgumentNullException: `query` is `null`

  • methodQueryAsync
    public async Task<IEnumerable<TReturn>> QueryAsync(IDbConnection connection, ISqlCompiler compiler, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes the multi-map query and returns an enumerable of hydrated root entities.

    connection: IDbConnection
    The database connection to execute the query on.
    compiler: ISqlCompiler
    The SQL compiler used to translate the query AST into SQL text.
    transaction: IDbTransaction?
    An optional transaction to execute within.
    commandTimeout: int?
    An optional command timeout in seconds.
    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 of hydrated `TReturn` instances.

    Exceptions: ArgumentNullException: `connection` or `compiler` is `null`; InvalidOperationException: No entity mappings have been registered, or the root type is missing a generated reader factory

  • methodQueryFirstOrDefaultAsync
    public async Task<TReturn?> QueryFirstOrDefaultAsync(IDbConnection connection, ISqlCompiler compiler, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes the multi-map query and returns the first result, or `null` if no rows are returned.

    connection: IDbConnection
    The database connection to execute the query on.
    compiler: ISqlCompiler
    The SQL compiler used to translate the query AST into SQL text.
    transaction: IDbTransaction?
    An optional transaction to execute within.
    commandTimeout: int?
    An optional command timeout in seconds.
    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 `TReturn` instance, or `null` if the result set is empty.

    Exceptions: ArgumentNullException: `connection` or `compiler` is `null`; InvalidOperationException: No entity mappings have been registered, or the root type is missing a generated reader factory

  • methodQueryGroupedAsync<TKey>
    public async Task<IEnumerable<TReturn>> QueryGroupedAsync<TKey>(IDbConnection connection, ISqlCompiler compiler, Func<TReturn, TKey> keySelector, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default) where TKey : notnull

    Executes the multi-map query and deduplicates root entities by key, grouping related child entities into 1:N collections.

    connection: IDbConnection
    The database connection.
    compiler: ISqlCompiler
    The SQL compiler used to translate the query AST into SQL text.
    keySelector: Func<TReturn, TKey>
    A function to extract the unique key identifying the root entity instance.
    transaction: IDbTransaction?
    An optional transaction to execute within.
    commandTimeout: int?
    An optional command timeout in seconds.
    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 of distinct `TReturn` instances with aggregated child relationships.

    Type parameters: TKey: The type of the root entity primary key. Exceptions: ArgumentNullException: `connection`, `compiler`, or `keySelector` is `null`; InvalidOperationException: No entity mappings have been registered, or the root type is missing a generated reader factory

  • methodQueryGroupedFirstOrDefaultAsync<TKey>
    public async Task<TReturn?> QueryGroupedFirstOrDefaultAsync<TKey>(IDbConnection connection, ISqlCompiler compiler, Func<TReturn, TKey> keySelector, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default) where TKey : notnull

    Executes the multi-map query with root deduplication and returns the first result, or `null` if no rows are returned.

    connection: IDbConnection
    The database connection.
    compiler: ISqlCompiler
    The SQL compiler used to translate the query AST into SQL text.
    keySelector: Func<TReturn, TKey>
    A function to extract the unique key identifying the root entity instance.
    transaction: IDbTransaction?
    An optional transaction to execute within.
    commandTimeout: int?
    An optional command timeout in seconds.
    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 hydrated `TReturn` instance with aggregated child relationships, or `null`.

    Type parameters: TKey: The type of the root entity primary key. Exceptions: ArgumentNullException: `connection`, `compiler`, or `keySelector` is `null`; InvalidOperationException: No entity mappings have been registered, or the root type is missing a generated reader factory

  • propertySplitOn
    public string SplitOn { get; }

    Gets the comma-separated string of split-on column names for all registered mappings.

  • propertyTypes
    public Type[] Types { get; }

    Gets an array of CLR types representing the root type followed by all registered related entity types.

class

MultiMapDescriptor

Ensamblado: EricksonLopez.DapperExtensions
public sealed class MultiMapDescriptor

Describes how to split and hydrate an entity type in a multi-mapping query result.

Notas:

`MultiMapDescriptor` is an extensibility surface for consumers who need to introspect or compose multi-map configurations at runtime — for example, when building dynamic multi-entity pipelines, diagnostic tooling, or custom query runners that sit outside of `MultiMapBuilder<TReturn>`. `MultiMapBuilder<TReturn>` does not use this descriptor internally; it manages mappings as lightweight anonymous tuples for performance. Consumers who need a typed, inspectable mapping descriptor can construct a `MultiMapDescriptor` alongside a `MultiMapBuilder<TReturn>` invocation.

Miembros (5)

  • constructorMultiMapDescriptor
    public MultiMapDescriptor(Type entityType, string tableName, string[] columnNames, Func<IDataReader, object> readerFactory)

    Initializes a new instance of the `MultiMapDescriptor` class.

    entityType: Type
    The CLR type of the entity.
    tableName: string
    The database table name associated with the entity.
    columnNames: string[]
    The column names occupied by this entity in the result set.
    readerFactory: Func<IDataReader, object>
    The factory delegate that hydrates an entity instance from an `IDataReader` row.
  • propertyColumnNames
    public string[] ColumnNames { get; }

    Gets the column names occupied by this entity in the result set.

  • propertyEntityType
    public Type EntityType { get; }

    Gets the CLR type of the entity.

  • propertyReaderFactory
    public Func<IDataReader, object> ReaderFactory { get; }

    Gets the factory delegate that hydrates an entity instance from an `IDataReader` row.

  • propertyTableName
    public string TableName { get; }

    Gets the database table name associated with the entity.

EricksonLopez.DapperExtensions.MySql.Bulk#

3
class

BulkBuilder

Ensamblado: EricksonLopez.DapperExtensions.MySql
public static class BulkBuilder

Provides factory methods for creating `BulkBuilder<T>` instances.

Miembros (1)

  • methodFrom<T>
    public static BulkBuilder<T> From<T>(IEnumerable<T> items)

    Begins building a bulk INSERT operation for the specified collection.

    items: IEnumerable<T>
    The collection of entities to insert.

    Retorna: A new `BulkBuilder<T>` instance.

    Type parameters: T: The entity type to bulk-insert. Exceptions: ArgumentNullException: `items` is `null`

class

BulkBuilder<T>

Ensamblado: EricksonLopez.DapperExtensions.MySql
public sealed class BulkBuilder<T>

Builds parameterized multi-row INSERT SQL statements and Dapper parameters for bulk operations on MySQL.

Notas:

MySQL uses multi-row VALUES syntax: `INSERT INTO `table` (`col1`, `col2`) VALUES (@p0_0, @p0_1), (@p1_0, @p1_1), ...` Type parameters: T: The entity type to bulk-insert.

Miembros (7)

  • methodBatchSize
    public BulkBuilder<T> BatchSize(int maxRowsPerBatch)

    Sets the maximum number of rows per generated SQL batch.

    maxRowsPerBatch: int
    The maximum rows per batch (must be greater than zero).

    Retorna: The current builder instance.

    Exceptions: ArgumentOutOfRangeException: `maxRowsPerBatch` is less than or equal to zero

  • methodBuild
    public (string? Sql, DynamicParameters? Parameters) Build()

    Builds the SQL INSERT statement and a `DynamicParameters` object containing all row values as named parameters. When the total parameter count exceeds `MaxParametersPerStatement`, safe parameter-bounded batches are registered for automatic chunked execution in `BulkExtensions.BulkInsertAsync(IDbConnection, string?, DynamicParameters?, IDbTransaction?, int?, CancellationToken)`.

    Retorna: A tuple containing the generated SQL text and parameter collection, or `(null, null)` if there are no items.

    Exceptions: InvalidOperationException: The destination table name or column mappings have not been configured

  • methodBuildBatches
    public IReadOnlyList<(string Sql, DynamicParameters Parameters)> BuildBatches()

    Builds one or more parameter-bounded SQL INSERT batches so large collections never exceed MySQL's parameter limit.

    Retorna: A read-only list of SQL and parameter batches.

    Exceptions: InvalidOperationException: The destination table name or column mappings have not been configured

  • methodColumn
    public BulkBuilder<T> Column(string columnName, Func<T, object?> selector)

    Adds a column mapping to the bulk INSERT operation.

    columnName: string
    The column name in the target table.
    selector: Func<T, object?>
    The delegate that extracts the column value from each entity item.

    Retorna: The current builder instance.

    Exceptions: ArgumentException: `columnName` is empty, whitespace, or contains null characters; ArgumentNullException: `selector` is `null`

  • methodTable
    public BulkBuilder<T> Table(string tableName)

    Sets the destination table name for the bulk INSERT operation.

    tableName: string
    The table name (or schema-qualified `schema.table`).

    Retorna: The current builder instance.

    Exceptions: ArgumentException: `tableName` is empty, whitespace, contains null characters, or has invalid schema segments

  • propertyCount
    public int Count { get; }

    Gets the number of items to be inserted.

  • fieldMaxParametersPerStatement
    public const int MaxParametersPerStatement

    Defines the maximum number of SQL parameters permitted in a single MySQL statement batch (MySQL prepared statement limit is 65,535).

class

BulkExtensions

Ensamblado: EricksonLopez.DapperExtensions.MySql
public static class BulkExtensions

Provides extension methods for bulk INSERT, UPSERT, UPDATE, and DELETE operations on MySQL connections.

Miembros (5)

  • methodBulkDeleteAsync
    public static Task<int> BulkDeleteAsync(this IDbConnection connection, string? sql, DynamicParameters? parameters, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk DELETE statement using pre-built SQL and parameters.

    connection: this IDbConnection
    The database connection to execute the command on.
    sql: string?
    The bulk DELETE SQL statement.
    parameters: DynamicParameters?
    The parameterized values for the bulk operation.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` is `null`

  • methodBulkInsertAsync
    public static async Task<int> BulkInsertAsync(this IDbConnection connection, string? sql, DynamicParameters? parameters, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk INSERT statement using pre-built SQL and parameters.

    connection: this IDbConnection
    The database connection to execute the command on.
    sql: string?
    The multi-row INSERT SQL statement.
    parameters: DynamicParameters?
    The parameterized values for the bulk insert.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` is `null`

  • methodBulkInsertAsync<T>
    public static async Task<int> BulkInsertAsync<T>(this IDbConnection connection, BulkBuilder<T> builder, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk INSERT statement using a configured `BulkBuilder<T>`, automatically chunking into safe parameter-bounded batches when needed.

    connection: this IDbConnection
    The database connection to execute the command on.
    builder: BulkBuilder<T>
    The configured bulk builder.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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 total number of rows affected across all batches.

    Type parameters: T: The entity type to bulk-insert. Exceptions: ArgumentNullException: `connection` or `builder` is `null`

  • methodBulkUpdateAsync
    public static Task<int> BulkUpdateAsync(this IDbConnection connection, string? sql, DynamicParameters? parameters, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk UPDATE statement using pre-built SQL and parameters.

    connection: this IDbConnection
    The database connection to execute the command on.
    sql: string?
    The bulk UPDATE SQL statement.
    parameters: DynamicParameters?
    The parameterized values for the bulk operation.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` is `null`

  • methodBulkUpsertAsync
    public static Task<int> BulkUpsertAsync(this IDbConnection connection, string? sql, DynamicParameters? parameters, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk INSERT ... ON DUPLICATE KEY UPDATE statement using pre-built SQL and parameters.

    connection: this IDbConnection
    The database connection to execute the command on.
    sql: string?
    The multi-row UPSERT SQL statement.
    parameters: DynamicParameters?
    The parameterized values for the bulk operation.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` is `null`

EricksonLopez.DapperExtensions.MySql.Pagination#

1
class

PagedQueryExtensions

Ensamblado: EricksonLopez.DapperExtensions.MySql
public static class PagedQueryExtensions

Provides extension methods for executing paginated queries with Dapper on MySQL databases.

Miembros (3)

  • methodQueryCursorPagedAsync<T>
    public static async Task<ICursorPagedList<T>> QueryCursorPagedAsync<T>(this IDbConnection connection, string sql, string cursorColumn, CursorPaginationParameters parameters, Func<T, string> cursorSelector, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a cursor-based (keyset) paginated query returning a cursor paged list.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The base SQL query without keyset filters or ordering.
    cursorColumn: string
    The column name used as the pagination cursor.
    parameters: CursorPaginationParameters
    The cursor pagination parameters containing page boundaries.
    cursorSelector: Func<T, string>
    The delegate that extracts the cursor value from an entity item.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a cursor paged list of `T` items.

    Type parameters: T: The entity type to map each result row to. Exceptions: ArgumentNullException: `connection` or `cursorSelector` is `null`; ArgumentException: `sql` or `cursorColumn` is empty or whitespace

  • methodQueryPagedAsync<T>
    public static async Task<ICountedPagedList<T>> QueryPagedAsync<T>(this IDbConnection connection, string sql, string countSql, PaginationParameters pagination, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes an offset-based paginated query using separate data and total count SQL statements.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The SQL statement to retrieve page data without pagination clauses.
    countSql: string
    The SQL statement to calculate the total record count.
    pagination: PaginationParameters
    The pagination parameters including page number and page size.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a counted paged list of `T` items.

    Type parameters: T: The entity type to map each result row to. Exceptions: ArgumentNullException: `connection` is `null`; ArgumentException: `sql` or `countSql` is empty or whitespace

  • methodQueryPagedMultipleAsync<T>
    public static async Task<ICountedPagedList<T>> QueryPagedMultipleAsync<T>(this IDbConnection connection, string sql, PaginationParameters pagination, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes an offset-based paginated query using a single multi-result SQL statement.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The SQL query returning two result sets: the page items followed by the total count.
    pagination: PaginationParameters
    The pagination parameters including page number and page size.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a counted paged list of `T` items.

    Type parameters: T: The entity type to map each result row to. Exceptions: ArgumentNullException: `connection` is `null`; ArgumentException: `sql` is empty or whitespace

EricksonLopez.DapperExtensions.MySql.Transactions#

1
class

TransactionExtensions

Ensamblado: EricksonLopez.DapperExtensions.MySql
public static class TransactionExtensions

Provides extension methods for executing operations within a MySQL transaction scope.

Miembros (2)

  • methodExecuteInTransactionAsync
    public static async Task ExecuteInTransactionAsync(this DbConnection connection, Func<DbTransaction, Task> operation, CancellationToken cancellationToken = default)

    Executes an asynchronous operation within a newly opened transaction, committing automatically on success and rolling back on failure.

    connection: this DbConnection
    The database connection to execute the transaction on.
    operation: Func<DbTransaction, Task>
    The asynchronous operation to execute within the active transaction.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

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

  • methodExecuteInTransactionAsync<TResult>
    public static async Task<TResult> ExecuteInTransactionAsync<TResult>(this DbConnection connection, Func<DbTransaction, Task<TResult>> operation, CancellationToken cancellationToken = default)

    Executes an asynchronous operation returning a result within a newly opened transaction, committing on success and rolling back on failure.

    connection: this DbConnection
    The database connection to execute the transaction on.
    operation: Func<DbTransaction, Task<TResult>>
    The asynchronous operation returning a result to execute within the active transaction.
    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 returned by `operation`.

    Type parameters: TResult: The type of the result returned by the operation. Exceptions: ArgumentNullException: `connection` or `operation` is `null`

EricksonLopez.DapperExtensions.MySql.TypeHandlers#

2
class

JsonTypeHandler<T>

Ensamblado: EricksonLopez.DapperExtensions.MySql
public sealed class JsonTypeHandler<T> : SqlMapper.TypeHandler<T>
Hereda de: SqlMapper.TypeHandler<T>

Provides a Dapper type handler for MySQL JSON columns using System.Text.Json serialization.

Notas:

Type parameters: T: The .NET type to serialize and deserialize.

Miembros (2)

  • methodParse
    public override T? Parse(object value)

    Inherits documentation from base type or interface.

    value: object
  • methodSetValue
    public override void SetValue(IDbDataParameter parameter, T? value)

    Inherits documentation from base type or interface.

    parameter: IDbDataParameter
    value: T?
class

MySqlTypeHandlerRegistrar

Ensamblado: EricksonLopez.DapperExtensions.MySql
public static class MySqlTypeHandlerRegistrar

Provides convenience registration methods for MySQL JSON type handlers.

Miembros (1)

  • methodRegisterJsonHandler<T>
    public static void RegisterJsonHandler<T>()

    Registers a JSON type handler for the specified type with Dapper.

    Type parameters: T: The .NET type to map to JSON columns.

EricksonLopez.DapperExtensions.OpenTelemetry#

4
class

DapperDiagnostics

Ensamblado: EricksonLopez.DapperExtensions.OpenTelemetry
public static class DapperDiagnostics

Provides diagnostic sources, meters, and semantic convention constants for OpenTelemetry instrumentation in Dapper extensions.

Miembros (17)

  • methodRecordResilienceRetry
    public static void RecordResilienceRetry(string? dbSystem = null, long retryCount = 1)

    Records a resilience retry execution in `ResilienceRetriesCounter` when metrics are enabled.

    dbSystem: string?
    The optional database system identifier tag.
    retryCount: long
    The number of retries to record. Defaults to 1.
  • propertyOptions
    public static DapperOpenTelemetryOptions Options { get; set; }

    Gets or sets the active configuration options for OpenTelemetry instrumentation.

  • fieldActivitySource
    public static readonly ActivitySource ActivitySource

    Gets the shared `Diagnostics.ActivitySource` instance for distributed tracing.

  • fieldBulkRowsCounter
    public static readonly Counter<long> BulkRowsCounter

    Gets the counter instrument tracking the total rows affected by high-throughput bulk operations.

  • fieldCommandDurationHistogram
    public static readonly Histogram<double> CommandDurationHistogram

    Gets the histogram instrument recording the execution duration of database commands in milliseconds.

  • fieldCommandExecutionsCounter
    public static readonly Counter<long> CommandExecutionsCounter

    Gets the counter instrument tracking the total number of executed database commands.

  • fieldMeter
    public static readonly Meter Meter

    Gets the shared `Metrics.Meter` instance for database metrics.

  • fieldResilienceRetriesCounter
    public static readonly Counter<long> ResilienceRetriesCounter

    Gets the counter instrument tracking resilience retry executions across pipelines.

  • fieldSourceName
    public const string SourceName

    Defines the diagnostic source name for tracing and metrics.

  • fieldTagDbName
    public const string TagDbName

    Defines the OpenTelemetry semantic convention attribute name for the database name.

  • fieldTagDbOperation
    public const string TagDbOperation

    Defines the OpenTelemetry semantic convention attribute name for the executed database operation.

  • fieldTagDbRowsAffected
    public const string TagDbRowsAffected

    Defines the OpenTelemetry semantic convention attribute name for the number of rows affected.

  • fieldTagDbStatement
    public const string TagDbStatement

    Defines the OpenTelemetry semantic convention attribute name for the executed database statement.

  • fieldTagDbSystem
    public const string TagDbSystem

    Defines the OpenTelemetry semantic convention attribute name for the database system identifier.

  • fieldTagErrorType
    public const string TagErrorType

    Defines the OpenTelemetry semantic convention attribute name for the error classification type.

  • fieldTagServerAddress
    public const string TagServerAddress

    Defines the OpenTelemetry semantic convention attribute name for the database server address.

  • fieldVersion
    public const string Version

    Defines the diagnostic instrumentation version.

class

DapperOpenTelemetryOptions

Ensamblado: EricksonLopez.DapperExtensions.OpenTelemetry
public sealed class DapperOpenTelemetryOptions

Represents configuration options for OpenTelemetry instrumentation in Dapper extensions.

Miembros (3)

  • propertyCaptureSqlStatements
    public bool CaptureSqlStatements { get; set; }

    Gets or sets a value indicating whether raw SQL statements should be included in activity tags. Defaults to `true`.

  • propertyEnableMetrics
    public bool EnableMetrics { get; set; }

    Gets or sets a value indicating whether metrics recording is enabled. Defaults to `true`.

  • propertyMaxStatementLength
    public int MaxStatementLength { get; set; }

    Gets or sets the maximum length of captured SQL statements before truncation. Defaults to 4096 characters.

class

DapperOpenTelemetryServiceCollectionExtensions

Ensamblado: EricksonLopez.DapperExtensions.OpenTelemetry
public static class DapperOpenTelemetryServiceCollectionExtensions

Provides extension methods for configuring OpenTelemetry instrumentation on `IServiceCollection`.

Miembros (1)

  • methodAddDapperOpenTelemetry
    public static IServiceCollection AddDapperOpenTelemetry(this IServiceCollection services, Action<DapperOpenTelemetryOptions>? configure = null)

    Adds Dapper OpenTelemetry configuration options to the specified service collection.

    services: this IServiceCollection
    The service collection to configure.
    configure: Action<DapperOpenTelemetryOptions>?
    The optional action to configure OpenTelemetry options.

    Retorna: The configured service collection.

    Exceptions: ArgumentNullException: `services` is `null`

class

OpenTelemetryDbConnectionExtensions

Ensamblado: EricksonLopez.DapperExtensions.OpenTelemetry
public static class OpenTelemetryDbConnectionExtensions

Provides extension methods for instrumenting database operations with OpenTelemetry tracing and metrics.

Miembros (5)

  • methodExecuteWithTelemetryAsync
    public static async Task<int> ExecuteWithTelemetryAsync(this IDbConnection connection, string sql, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CommandType? commandType = null, CancellationToken cancellationToken = default)

    Executes a SQL command instrumented with OpenTelemetry activity tracing and duration metrics.

    connection: this IDbConnection
    The database connection to execute the command on.
    sql: string
    The SQL statement to execute.
    param: object?
    The optional command parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    commandType: CommandType?
    The optional command type.
    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: `connection` is `null`; ArgumentException: `sql` is empty or whitespace

  • methodQueryWithTelemetryAsync<T>
    public static async Task<IEnumerable<T>> QueryWithTelemetryAsync<T>(this IDbConnection connection, string sql, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CommandType? commandType = null, CancellationToken cancellationToken = default)

    Executes a SQL query instrumented with OpenTelemetry activity tracing and duration metrics.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The SQL query to execute.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    commandType: CommandType?
    The optional command type.
    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 sequence of mapped `T` instances.

    Type parameters: T: The target entity type to map each row to. Exceptions: ArgumentNullException: `connection` is `null`; ArgumentException: `sql` is empty or whitespace

  • methodTraceBulkOperationAsync
    public static async Task<int> TraceBulkOperationAsync(this IDbConnection connection, string operationName, string targetTable, Func<CancellationToken, Task<int>> bulkAction, CancellationToken cancellationToken = default)

    Instruments a bulk operation delegate with OpenTelemetry activity tracing and records affected bulk rows.

    connection: this IDbConnection
    The database connection.
    operationName: string
    The name of the bulk operation being performed (e.g., BulkInsert, BulkUpdate).
    targetTable: string
    The name of the target database table.
    bulkAction: Func<CancellationToken, Task<int>>
    The asynchronous bulk execution delegate returning the number of rows affected.
    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: `connection` or `bulkAction` is `null`

  • methodTracedExecuteAsync
    public static async Task<int> TracedExecuteAsync(this System.Data.Common.DbConnection connection, string sql, object? param = null, string? dbSystem = null, IDbTransaction? transaction = null, int? commandTimeout = null, CommandType? commandType = null, CancellationToken cancellationToken = default)

    Executes a SQL command on a `Common.DbConnection` instrumented with OpenTelemetry activity tracing and metrics, using an explicit database system identifier.

    connection: this System.Data.Common.DbConnection
    The database connection to execute the command on.
    sql: string
    The SQL statement to execute.
    param: object?
    The optional command parameters.
    dbSystem: string?
    The database system identifier (e.g., `postgresql`, `mssql`). When `null` or whitespace, it is inferred from the connection type.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    commandType: CommandType?
    The optional command type.
    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: `connection` is `null`; ArgumentException: `sql` is empty or whitespace

  • methodTracedQueryAsync<T>
    public static async Task<IEnumerable<T>> TracedQueryAsync<T>(this System.Data.Common.DbConnection connection, string sql, object? param = null, string? dbSystem = null, IDbTransaction? transaction = null, int? commandTimeout = null, CommandType? commandType = null, CancellationToken cancellationToken = default)

    Executes a SQL query on a `Common.DbConnection` instrumented with OpenTelemetry activity tracing and metrics, using an explicit database system identifier.

    connection: this System.Data.Common.DbConnection
    The database connection to execute the query on.
    sql: string
    The SQL query to execute.
    param: object?
    The optional query parameters.
    dbSystem: string?
    The database system identifier (e.g., `postgresql`, `mssql`). When `null` or whitespace, it is inferred from the connection type.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    commandType: CommandType?
    The optional command type.
    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 sequence of mapped `T` instances.

    Type parameters: T: The target entity type to map each row to. Exceptions: ArgumentNullException: `connection` is `null`; ArgumentException: `sql` is empty or whitespace

EricksonLopez.DapperExtensions.Oracle.Bulk#

3
class

BulkBuilder

Ensamblado: EricksonLopez.DapperExtensions.Oracle
public static class BulkBuilder

Provides factory methods for creating `BulkBuilder<T>` instances.

Miembros (1)

  • methodFrom<T>
    public static BulkBuilder<T> From<T>(IEnumerable<T> items)

    Begins building a bulk INSERT operation for the specified collection.

    items: IEnumerable<T>
    The collection of entities to insert.

    Retorna: A new `BulkBuilder<T>` instance.

    Type parameters: T: The entity type to bulk-insert. Exceptions: ArgumentNullException: `items` is `null`

class

BulkBuilder<T>

Ensamblado: EricksonLopez.DapperExtensions.Oracle
public sealed class BulkBuilder<T>

Builds parameterized INSERT ALL SQL statements and Dapper parameters for bulk operations on Oracle Database.

Notas:

Oracle supports multi-row inserts via the `INSERT ALL INTO table VALUES (...) SELECT 1 FROM DUAL` syntax. Type parameters: T: The entity type to bulk-insert.

Miembros (7)

  • methodBatchSize
    public BulkBuilder<T> BatchSize(int maxRowsPerBatch)

    Sets the maximum number of rows per generated SQL batch.

    maxRowsPerBatch: int
    The maximum rows per batch (must be greater than zero).

    Retorna: The current builder instance.

    Exceptions: ArgumentOutOfRangeException: `maxRowsPerBatch` is less than or equal to zero

  • methodBuild
    public (string? Sql, DynamicParameters? Parameters) Build()

    Builds the SQL INSERT statement and a `DynamicParameters` object containing all row values as named parameters. When the total parameter count exceeds `MaxParametersPerStatement`, safe parameter-bounded batches are registered for automatic chunked execution in `BulkExtensions.BulkInsertAsync(IDbConnection, string?, DynamicParameters?, IDbTransaction?, int?, CancellationToken)`.

    Retorna: A tuple containing the generated SQL text and parameter collection, or `(null, null)` if there are no items.

    Exceptions: InvalidOperationException: The destination table name or column mappings have not been configured

  • methodBuildBatches
    public IReadOnlyList<(string Sql, DynamicParameters Parameters)> BuildBatches()

    Builds one or more parameter-bounded SQL INSERT batches so large collections never exceed Oracle's bind variable limit.

    Retorna: A read-only list of SQL and parameter batches.

    Exceptions: InvalidOperationException: The destination table name or column mappings have not been configured

  • methodColumn
    public BulkBuilder<T> Column(string columnName, Func<T, object?> selector)

    Adds a column mapping to the bulk INSERT operation.

    columnName: string
    The column name in the target table.
    selector: Func<T, object?>
    The delegate that extracts the column value from each entity item.

    Retorna: The current builder instance.

    Exceptions: ArgumentException: `columnName` is empty, whitespace, or contains null characters; ArgumentNullException: `selector` is `null`

  • methodTable
    public BulkBuilder<T> Table(string tableName)

    Sets the destination table name for the bulk INSERT operation.

    tableName: string
    The table name (or schema-qualified `schema.table`).

    Retorna: The current builder instance.

    Exceptions: ArgumentException: `tableName` is empty, whitespace, contains null characters, or has invalid schema segments

  • propertyCount
    public int Count { get; }

    Gets the number of items to be inserted.

  • fieldMaxParametersPerStatement
    public const int MaxParametersPerStatement

    Defines the maximum number of SQL bind variables permitted in a single Oracle statement batch (Oracle bind limit is 65,535).

class

BulkExtensions

Ensamblado: EricksonLopez.DapperExtensions.Oracle
public static class BulkExtensions

Provides extension methods for bulk INSERT, UPSERT, UPDATE, and DELETE operations on Oracle Database connections.

Miembros (5)

  • methodBulkDeleteAsync
    public static Task<int> BulkDeleteAsync(this IDbConnection connection, string? sql, DynamicParameters? parameters, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk DELETE statement using pre-built SQL and parameters.

    connection: this IDbConnection
    The database connection to execute the command on.
    sql: string?
    The bulk DELETE SQL statement.
    parameters: DynamicParameters?
    The parameterized values for the bulk operation.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` is `null`

  • methodBulkInsertAsync
    public static async Task<int> BulkInsertAsync(this IDbConnection connection, string? sql, DynamicParameters? parameters, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk INSERT statement using pre-built SQL and parameters.

    connection: this IDbConnection
    The database connection to execute the command on.
    sql: string?
    The multi-row INSERT SQL statement.
    parameters: DynamicParameters?
    The parameterized values for the bulk insert.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` is `null`

  • methodBulkInsertAsync<T>
    public static async Task<int> BulkInsertAsync<T>(this IDbConnection connection, BulkBuilder<T> builder, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk INSERT statement using a configured `BulkBuilder<T>`, automatically chunking into safe parameter-bounded batches when needed.

    connection: this IDbConnection
    The database connection to execute the command on.
    builder: BulkBuilder<T>
    The configured bulk builder.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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 total number of rows affected across all batches.

    Type parameters: T: The entity type to bulk-insert. Exceptions: ArgumentNullException: `connection` or `builder` is `null`

  • methodBulkUpdateAsync
    public static Task<int> BulkUpdateAsync(this IDbConnection connection, string? sql, DynamicParameters? parameters, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk UPDATE statement using pre-built SQL and parameters.

    connection: this IDbConnection
    The database connection to execute the command on.
    sql: string?
    The bulk UPDATE SQL statement.
    parameters: DynamicParameters?
    The parameterized values for the bulk operation.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` is `null`

  • methodBulkUpsertAsync
    public static Task<int> BulkUpsertAsync(this IDbConnection connection, string? sql, DynamicParameters? parameters, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk MERGE (upsert) statement using pre-built SQL and parameters.

    connection: this IDbConnection
    The database connection to execute the command on.
    sql: string?
    The multi-row MERGE SQL statement.
    parameters: DynamicParameters?
    The parameterized values for the bulk operation.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` is `null`

EricksonLopez.DapperExtensions.Oracle.Pagination#

1
class

PagedQueryExtensions

Ensamblado: EricksonLopez.DapperExtensions.Oracle
public static class PagedQueryExtensions

Provides extension methods for executing paginated queries with Dapper on Oracle databases.

Miembros (3)

  • methodQueryCursorPagedAsync<T>
    public static async Task<ICursorPagedList<T>> QueryCursorPagedAsync<T>(this IDbConnection connection, string sql, string cursorColumn, CursorPaginationParameters parameters, Func<T, string> cursorSelector, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a cursor-based (keyset) paginated query returning a cursor paged list.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The base SQL query without keyset filters or ordering.
    cursorColumn: string
    The column name used as the pagination cursor.
    parameters: CursorPaginationParameters
    The cursor pagination parameters containing page boundaries.
    cursorSelector: Func<T, string>
    The delegate that extracts the cursor value from an entity item.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a cursor paged list of `T` items.

    Type parameters: T: The entity type to map each result row to. Exceptions: ArgumentNullException: `connection` or `cursorSelector` is `null`; ArgumentException: `sql` or `cursorColumn` is empty or whitespace

  • methodQueryPagedAsync<T>
    public static async Task<ICountedPagedList<T>> QueryPagedAsync<T>(this IDbConnection connection, string sql, string countSql, PaginationParameters pagination, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes an offset-based paginated query using separate data and total count SQL statements.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The SQL statement to retrieve page data without pagination clauses.
    countSql: string
    The SQL statement to calculate the total record count.
    pagination: PaginationParameters
    The pagination parameters including page number and page size.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a counted paged list of `T` items.

    Type parameters: T: The entity type to map each result row to. Exceptions: ArgumentNullException: `connection` is `null`; ArgumentException: `sql` or `countSql` is empty or whitespace

  • methodQueryPagedMultipleAsync<T>
    public static async Task<ICountedPagedList<T>> QueryPagedMultipleAsync<T>(this IDbConnection connection, string sql, PaginationParameters pagination, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes an offset-based paginated query using a single multi-result SQL statement.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The SQL query returning two result sets: the page items followed by the total count.
    pagination: PaginationParameters
    The pagination parameters including page number and page size.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a counted paged list of `T` items.

    Type parameters: T: The entity type to map each result row to. Exceptions: ArgumentNullException: `connection` is `null`; ArgumentException: `sql` is empty or whitespace

EricksonLopez.DapperExtensions.Oracle.Transactions#

1
class

TransactionExtensions

Ensamblado: EricksonLopez.DapperExtensions.Oracle
public static class TransactionExtensions

Provides extension methods for executing operations within an Oracle Database transaction scope.

Miembros (2)

  • methodExecuteInTransactionAsync
    public static async Task ExecuteInTransactionAsync(this DbConnection connection, Func<DbTransaction, Task> operation, CancellationToken cancellationToken = default)

    Executes an asynchronous operation within a newly opened transaction, committing automatically on success and rolling back on failure.

    connection: this DbConnection
    The database connection to execute the transaction on.
    operation: Func<DbTransaction, Task>
    The asynchronous operation to execute within the active transaction.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

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

  • methodExecuteInTransactionAsync<TResult>
    public static async Task<TResult> ExecuteInTransactionAsync<TResult>(this DbConnection connection, Func<DbTransaction, Task<TResult>> operation, CancellationToken cancellationToken = default)

    Executes an asynchronous operation returning a result within a newly opened transaction, committing on success and rolling back on failure.

    connection: this DbConnection
    The database connection to execute the transaction on.
    operation: Func<DbTransaction, Task<TResult>>
    The asynchronous operation returning a result to execute within the active transaction.
    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 returned by `operation`.

    Type parameters: TResult: The type of the result returned by the operation. Exceptions: ArgumentNullException: `connection` or `operation` is `null`

EricksonLopez.DapperExtensions.Oracle.TypeHandlers#

2
class

JsonTypeHandler<T>

Ensamblado: EricksonLopez.DapperExtensions.Oracle
public sealed class JsonTypeHandler<T> : SqlMapper.TypeHandler<T>
Hereda de: SqlMapper.TypeHandler<T>

Provides a Dapper type handler for Oracle JSON columns using System.Text.Json serialization.

Notas:

Type parameters: T: The .NET type to serialize and deserialize.

Miembros (2)

  • methodParse
    public override T? Parse(object value)

    Inherits documentation from base type or interface.

    value: object
  • methodSetValue
    public override void SetValue(IDbDataParameter parameter, T? value)

    Inherits documentation from base type or interface.

    parameter: IDbDataParameter
    value: T?
class

OracleTypeHandlerRegistrar

Ensamblado: EricksonLopez.DapperExtensions.Oracle
public static class OracleTypeHandlerRegistrar

Provides convenience registration methods for Oracle JSON type handlers.

Miembros (1)

  • methodRegisterJsonHandler<T>
    public static void RegisterJsonHandler<T>()

    Registers a JSON type handler for the specified type with Dapper.

    Type parameters: T: The .NET type to map to JSON columns.

EricksonLopez.DapperExtensions.PostgreSql.Bulk#

3
class

BulkExtensions

Ensamblado: EricksonLopez.DapperExtensions.PostgreSql
public static class BulkExtensions

Provides extension methods for bulk INSERT, UPSERT, UPDATE, and DELETE operations using PostgreSQL UNNEST.

Miembros (4)

  • methodBulkDeleteAsync
    public static Task<int> BulkDeleteAsync(this DbConnection connection, string sql, NpgsqlParameter[] parameters, DbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk DELETE statement using PostgreSQL UNNEST array parameters.

    connection: this DbConnection
    The database connection to execute the command on.
    sql: string
    The SQL DELETE statement utilizing array criteria or UNNEST.
    parameters: NpgsqlParameter[]
    The array parameters built with `BulkParameters<T>`.
    transaction: DbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` or `parameters` is `null`; ArgumentException: `sql` is empty or whitespace

  • methodBulkInsertAsync
    public static async Task<int> BulkInsertAsync(this DbConnection connection, string sql, NpgsqlParameter[] parameters, DbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk INSERT statement using PostgreSQL UNNEST array parameters.

    connection: this DbConnection
    The database connection to execute the command on.
    sql: string
    The SQL INSERT...SELECT FROM UNNEST(...) statement.
    parameters: NpgsqlParameter[]
    The array parameters built with `BulkParameters<T>`.
    transaction: DbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` or `parameters` is `null`; ArgumentException: `sql` is empty or whitespace

  • methodBulkUpdateAsync
    public static Task<int> BulkUpdateAsync(this DbConnection connection, string sql, NpgsqlParameter[] parameters, DbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk UPDATE statement using PostgreSQL UNNEST array parameters.

    connection: this DbConnection
    The database connection to execute the command on.
    sql: string
    The SQL UPDATE statement joining against UNNEST.
    parameters: NpgsqlParameter[]
    The array parameters built with `BulkParameters<T>`.
    transaction: DbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` or `parameters` is `null`; ArgumentException: `sql` is empty or whitespace

  • methodBulkUpsertAsync
    public static Task<int> BulkUpsertAsync(this DbConnection connection, string sql, NpgsqlParameter[] parameters, DbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk INSERT ... ON CONFLICT DO UPDATE (upsert) statement using PostgreSQL UNNEST array parameters.

    connection: this DbConnection
    The database connection to execute the command on.
    sql: string
    The SQL INSERT...SELECT FROM UNNEST(...) ON CONFLICT statement.
    parameters: NpgsqlParameter[]
    The array parameters built with `BulkParameters<T>`.
    transaction: DbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` or `parameters` is `null`; ArgumentException: `sql` is empty or whitespace

class

BulkParameters

Ensamblado: EricksonLopez.DapperExtensions.PostgreSql
public static class BulkParameters

Provides factory methods for creating `BulkParameters<T>` instances.

Miembros (1)

  • methodFrom<T>
    public static BulkParameters<T> From<T>(IEnumerable<T> items)

    Begins building bulk parameters for the specified collection.

    items: IEnumerable<T>
    The collection of entities to insert.

    Retorna: A new `BulkParameters<T>` instance.

    Type parameters: T: The entity type to bulk-insert. Exceptions: ArgumentNullException: `items` is `null`

class

BulkParameters<T>

Ensamblado: EricksonLopez.DapperExtensions.PostgreSql
public sealed class BulkParameters<T>

Builds typed array parameters for PostgreSQL UNNEST bulk operations.

Notas:

PostgreSQL supports bulk inserts via the `UNNEST` function: `INSERT INTO table (col1, col2) SELECT * FROM UNNEST(@col1, @col2)` Type parameters: T: The entity type to bulk-insert.

Miembros (3)

  • methodAdd<TValue>
    public BulkParameters<T> Add<TValue>(string parameterName, Func<T, TValue> selector, NpgsqlDbType dbType)

    Adds a column mapping with a PostgreSQL database type.

    parameterName: string
    The UNNEST parameter name without the '@' prefix.
    selector: Func<T, TValue>
    The delegate that extracts the column value from each entity item.
    dbType: NpgsqlDbType
    The PostgreSQL type of the column.

    Retorna: The current builder instance.

    Type parameters: TValue: The CLR type of the column elements. Exceptions: ArgumentException: `parameterName` is empty or whitespace; ArgumentNullException: `selector` is `null`

  • methodBuild
    public NpgsqlParameter[] Build()

    Builds the `NpgsqlParameter` array ready to pass to bulk execution methods.

    Retorna: An array of `NpgsqlParameter` instances populated with typed array values.

    Exceptions: InvalidOperationException: No columns have been registered via Add()

  • propertyCount
    public int Count { get; }

    Gets the number of items that will be inserted.

EricksonLopez.DapperExtensions.PostgreSql.Configuration#

1
class

PostgreSqlConnectionOptions

Ensamblado: EricksonLopez.DapperExtensions.PostgreSql
public sealed class PostgreSqlConnectionOptions

Validated PostgreSQL connection options enforcing least-privilege runtime database roles (`RejectSuperuserUsername = true`) so Row-Level Security (`FORCE ROW LEVEL SECURITY`) cannot be silently bypassed by connecting as `postgres`.

Miembros (3)

  • methodValidateOrThrow
    public void ValidateOrThrow()

    Validates this options instance and throws `InvalidOperationException` when misconfigured or using a prohibited superuser role.

  • propertyConnectionString
    public string ConnectionString { get; set; }

    Gets or sets the runtime PostgreSQL connection string.

  • propertyRejectSuperuserUsername
    public bool RejectSuperuserUsername { get; set; }

    Gets or sets a value indicating whether runtime connections using the `postgres` superuser account must be rejected at startup. Default is `true`.

EricksonLopez.DapperExtensions.PostgreSql.Pagination#

1
class

PagedQueryExtensions

Ensamblado: EricksonLopez.DapperExtensions.PostgreSql
public static class PagedQueryExtensions

Provides extension methods for executing paginated queries with Dapper on PostgreSQL databases.

Miembros (3)

  • methodQueryCursorPagedAsync<T>
    public static async Task<ICursorPagedList<T>> QueryCursorPagedAsync<T>(this IDbConnection connection, string sql, string cursorColumn, CursorPaginationParameters parameters, Func<T, string> cursorSelector, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a cursor-based (keyset) paginated query returning a cursor paged list.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The base SQL query without keyset filters or ordering.
    cursorColumn: string
    The column name used as the pagination cursor.
    parameters: CursorPaginationParameters
    The cursor pagination parameters containing page boundaries.
    cursorSelector: Func<T, string>
    The delegate that extracts the cursor value from an entity item.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a cursor paged list of `T` items.

    Type parameters: T: The entity type to map each result row to. Exceptions: ArgumentNullException: `connection` or `cursorSelector` is `null`; ArgumentException: `sql` or `cursorColumn` is empty or whitespace

  • methodQueryPagedAsync<T>
    public static async Task<ICountedPagedList<T>> QueryPagedAsync<T>(this IDbConnection connection, string sql, string countSql, PaginationParameters pagination, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes an offset-based paginated query using separate data and total count SQL statements.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The SQL statement to retrieve page data without pagination clauses.
    countSql: string
    The SQL statement to calculate the total record count.
    pagination: PaginationParameters
    The pagination parameters including page number and page size.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a counted paged list of `T` items.

    Type parameters: T: The entity type to map each result row to. Exceptions: ArgumentNullException: `connection` is `null`; ArgumentException: `sql` or `countSql` is empty or whitespace

  • methodQueryPagedMultipleAsync<T>
    public static async Task<ICountedPagedList<T>> QueryPagedMultipleAsync<T>(this IDbConnection connection, string sql, PaginationParameters pagination, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes an offset-based paginated query using a single multi-result SQL statement.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The SQL query returning two result sets: the page items followed by the total count.
    pagination: PaginationParameters
    The pagination parameters including page number and page size.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a counted paged list of `T` items.

    Type parameters: T: The entity type to map each result row to. Exceptions: ArgumentNullException: `connection` is `null`; ArgumentException: `sql` is empty or whitespace

EricksonLopez.DapperExtensions.PostgreSql.Transactions#

1
class

TransactionExtensions

Ensamblado: EricksonLopez.DapperExtensions.PostgreSql
public static class TransactionExtensions

Provides extension methods for executing operations within a PostgreSQL transaction scope.

Miembros (2)

  • methodExecuteInTransactionAsync
    public static async Task ExecuteInTransactionAsync(this DbConnection connection, Func<DbTransaction, Task> operation, CancellationToken cancellationToken = default)

    Executes an asynchronous operation within a newly opened transaction, committing automatically on success and rolling back on failure.

    connection: this DbConnection
    The database connection to execute the transaction on.
    operation: Func<DbTransaction, Task>
    The asynchronous operation to execute within the active transaction.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

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

  • methodExecuteInTransactionAsync<TResult>
    public static async Task<TResult> ExecuteInTransactionAsync<TResult>(this DbConnection connection, Func<DbTransaction, Task<TResult>> operation, CancellationToken cancellationToken = default)

    Executes an asynchronous operation returning a result within a newly opened transaction, committing on success and rolling back on failure.

    connection: this DbConnection
    The database connection to execute the transaction on.
    operation: Func<DbTransaction, Task<TResult>>
    The asynchronous operation returning a result to execute within the active transaction.
    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 returned by `operation`.

    Type parameters: TResult: The type of the result returned by the operation. Exceptions: ArgumentNullException: `connection` or `operation` is `null`

EricksonLopez.DapperExtensions.PostgreSql.TypeHandlers#

2
class

JsonbTypeHandler<T>

Ensamblado: EricksonLopez.DapperExtensions.PostgreSql
public sealed class JsonbTypeHandler<T> : SqlMapper.TypeHandler<T>
Hereda de: SqlMapper.TypeHandler<T>

Provides a Dapper type handler for PostgreSQL JSONB columns using System.Text.Json serialization.

Notas:

Type parameters: T: The .NET type to serialize and deserialize.

Miembros (4)

  • constructorJsonbTypeHandler
    public JsonbTypeHandler()

    Initializes a new instance of the `JsonbTypeHandler<T>` class using default reflection-based serialization options.

  • constructorJsonbTypeHandler
    public JsonbTypeHandler(System.Text.Json.Serialization.Metadata.JsonTypeInfo<T> jsonTypeInfo)

    Initializes a new instance of the `JsonbTypeHandler<T>` class using source-generated `Metadata.JsonTypeInfo<T>` metadata.

    jsonTypeInfo: System.Text.Json.Serialization.Metadata.JsonTypeInfo<T>
    The source-generated JSON type metadata.

    Exceptions: ArgumentNullException: `jsonTypeInfo` is `null`

  • methodParse
    public override T? Parse(object value)

    Inherits documentation from base type or interface.

    value: object
  • methodSetValue
    public override void SetValue(IDbDataParameter parameter, T? value)

    Inherits documentation from base type or interface.

    parameter: IDbDataParameter
    value: T?
class

NpgsqlTypeHandlerRegistrar

Ensamblado: EricksonLopez.DapperExtensions.PostgreSql
public static class NpgsqlTypeHandlerRegistrar

Provides convenience registration methods for PostgreSQL JSONB type handlers.

Miembros (1)

  • methodRegisterJsonbHandler<T>
    public static void RegisterJsonbHandler<T>()

    Registers a JSONB type handler for the specified type with Dapper.

    Type parameters: T: The .NET type to map to JSONB columns.

EricksonLopez.DapperExtensions.Resilience#

9
interface

ISqlTransientErrorDetector

Ensamblado: EricksonLopez.DapperExtensions
public interface ISqlTransientErrorDetector

Defines a mechanism for determining whether a database exception represents a transient failure that can be safely retried.

Notas:

A transient error is caused by a temporary condition (such as connection timeouts, deadlocks, or failover events) rather than a permanent defect (such as constraint violations or syntax errors). Architectural Role & Convergence: In the unified EricksonLopez ecosystem, `ISqlTransientErrorDetector` provides database-specific classification of errors, feeding into the centralized `EricksonLopez.Resilience` engine (`IErrorClassifier`). `DapperExtensions` classifies the database operation context, while `EricksonLopez.Resilience` determines and orchestrates the retry/circuit-breaker policy. Critical rule: Only wrap the entire transactional unit with a retry policy. Never retry individual SQL statements inside an existing transaction.

Miembros (1)

  • methodIsTransient
    bool IsTransient(Exception exception)

    Determines whether the specified exception represents a transient database error.

    exception: Exception
    The exception to evaluate.

    Retorna: `true` if the error is transient and the operation can be retried; otherwise, `false`.

class

MySqlTransientErrorDetector

Ensamblado: EricksonLopez.DapperExtensions
public sealed class MySqlTransientErrorDetector : ISqlTransientErrorDetector
Implementa: ISqlTransientErrorDetector

Provides transient error detection for MySQL and MariaDB databases.

Notas:

- 1213 — ER_LOCK_DEADLOCK (deadlock found) - 1205 — ER_LOCK_WAIT_TIMEOUT (lock wait timeout exceeded) - 2006 — CR_SERVER_GONE_ERROR (MySQL server has gone away) - 2013 — CR_SERVER_LOST (lost connection to server) - 1158 — ER_NET_READ_ERROR (network read error) - 1159 — ER_NET_READ_INTERRUPTED (connection read interrupted) - 1160 — ER_NET_ERROR_ON_WRITE (network write error) - 1161 — ER_NET_WRITE_INTERRUPTED (connection write interrupted)

Miembros (2)

  • methodIsTransient
    public bool IsTransient(Exception exception)

    Determines whether the specified exception represents a transient database error.

    exception: Exception
    The exception to evaluate.

    Retorna: `true` if the error is transient and the operation can be retried; otherwise, `false`.

  • propertyDefault
    public static MySqlTransientErrorDetector Default { get; }

    Gets the default singleton instance of the `MySqlTransientErrorDetector` class.

class

OracleTransientErrorDetector

Ensamblado: EricksonLopez.DapperExtensions
public sealed class OracleTransientErrorDetector : ISqlTransientErrorDetector
Implementa: ISqlTransientErrorDetector

Provides transient error detection for Oracle databases.

Notas:

Oracle error codes that indicate transient conditions (per Oracle documentation): - ORA-00060 — Deadlock detected while waiting for resource. - ORA-08177 — Can't serialize access for this transaction (serialization failure). - ORA-03113 — End-of-file on communication channel (connection lost). - ORA-03114 — Not connected to ORACLE. - ORA-03135 — Connection lost contact (network). - ORA-12170 — Connect timeout occurred. - ORA-12541 — TNS: no listener (listener not available yet after failover). - ORA-12560 — TNS: protocol adapter error (connection reset). - ORA-12571 — TNS: packet writer failure. - ORA-00018 — Maximum number of sessions exceeded (resource exhaustion, transient). - ORA-00054 — Resource busy and acquire with NOWAIT specified (row-level lock). For `Oracle.ManagedDataAccess` / `Oracle.ManagedDataAccess.Client.OracleException`, the numeric code is available via the `Number` property, accessed here via cached reflection to avoid a hard dependency on the Oracle NuGet packages in the core assembly.

Miembros (2)

  • methodIsTransient
    public bool IsTransient(Exception exception)

    Determines whether the specified exception represents a transient database error.

    exception: Exception
    The exception to evaluate.

    Retorna: `true` if the error is transient and the operation can be retried; otherwise, `false`.

  • propertyDefault
    public static OracleTransientErrorDetector Default { get; }

    Gets the default singleton instance of the `OracleTransientErrorDetector` class.

class

PostgreSqlTransientErrorDetector

Ensamblado: EricksonLopez.DapperExtensions
public sealed class PostgreSqlTransientErrorDetector : ISqlTransientErrorDetector
Implementa: ISqlTransientErrorDetector

Provides transient error detection for PostgreSQL databases.

Notas:

Uses PostgreSQL SQLSTATE codes per the PostgreSQL documentation. - 40001 — serialization_failure (REPEATABLE READ / SERIALIZABLE conflicts) - 40P01 — deadlock_detected - 08006 — connection_failure - 08001 — sqlclient_unable_to_establish_sqlconnection - 08004 — sqlserver_rejected_establishment_of_sqlconnection - 57P01 — admin_shutdown (server restarting) - 57P02 — crash_shutdown - 57P03 — cannot_connect_now (startup in progress)

Miembros (2)

  • methodIsTransient
    public bool IsTransient(Exception exception)

    Determines whether the specified exception represents a transient database error.

    exception: Exception
    The exception to evaluate.

    Retorna: `true` if the error is transient and the operation can be retried; otherwise, `false`.

  • propertyDefault
    public static PostgreSqlTransientErrorDetector Default { get; }

    Gets the default singleton instance of the `PostgreSqlTransientErrorDetector` class.

class

SavepointResilienceExtensions

Ensamblado: EricksonLopez.DapperExtensions
public static class SavepointResilienceExtensions

Provides extension methods for executing transactional operations wrapped with savepoints and resilience pipelines.

Notas:

Retrying individual operations inside an open transaction can corrupt transactional state on relational engines unless intermediate failed operations are rolled back to a savepoint before each retry attempt. Architecture: Overloads accepting `IResiliencePipeline` are the canonical API aligned with the EricksonLopez.Resilience ecosystem. See ADR-014 and ADR-017.

Miembros (4)

  • methodExecuteInSavepointWithRetryAsync
    public static async Task ExecuteInSavepointWithRetryAsync(this IUnitOfWork unitOfWork, IResiliencePipeline pipeline, Func<IUnitOfWork, CancellationToken, Task> operation, string? savepointName = null, CancellationToken cancellationToken = default)

    Executes an asynchronous operation inside a database savepoint using the specified `IResiliencePipeline`.

    unitOfWork: this IUnitOfWork
    The unit of work managing the active database transaction.
    pipeline: IResiliencePipeline
    The resilience pipeline used to execute the retry strategy.
    operation: Func<IUnitOfWork, CancellationToken, Task>
    The asynchronous operation to execute within the savepoint scope.
    savepointName: string?
    The optional custom savepoint name. If `null`, a unique name is generated automatically.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

    Exceptions: ArgumentNullException: `unitOfWork`, `pipeline`, or `operation` is `null`

  • methodExecuteInSavepointWithRetryAsync
    public static Task ExecuteInSavepointWithRetryAsync(this IUnitOfWork unitOfWork, ResiliencePipeline pipeline, Func<IUnitOfWork, CancellationToken, Task> operation, string? savepointName = null, CancellationToken cancellationToken = default)

    Executes an asynchronous operation inside a database savepoint using the specified resilience pipeline.

    unitOfWork: this IUnitOfWork
    The unit of work managing the active database transaction.
    pipeline: ResiliencePipeline
    The resilience pipeline used to execute the retry strategy.
    operation: Func<IUnitOfWork, CancellationToken, Task>
    The asynchronous operation to execute within the savepoint scope.
    savepointName: string?
    The optional custom savepoint name. If `null`, a unique name is generated automatically.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

    Exceptions: ArgumentNullException: `unitOfWork`, `pipeline`, or `operation` is `null`

  • methodExecuteInSavepointWithRetryAsync<TResult>
    public static async Task<TResult> ExecuteInSavepointWithRetryAsync<TResult>(this IUnitOfWork unitOfWork, IResiliencePipeline pipeline, Func<IUnitOfWork, CancellationToken, Task<TResult>> operation, string? savepointName = null, CancellationToken cancellationToken = default)

    Executes an asynchronous operation that returns a value inside a database savepoint using the specified `IResiliencePipeline`.

    unitOfWork: this IUnitOfWork
    The unit of work managing the active database transaction.
    pipeline: IResiliencePipeline
    The resilience pipeline used to execute the retry strategy.
    operation: Func<IUnitOfWork, CancellationToken, Task<TResult>>
    The asynchronous operation returning a value to execute within the savepoint scope.
    savepointName: string?
    The optional custom savepoint name. If `null`, a unique name is generated automatically.
    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 returned by `operation`.

    Type parameters: TResult: The type of the result returned by the operation. Exceptions: ArgumentNullException: `unitOfWork`, `pipeline`, or `operation` is `null`

  • methodExecuteInSavepointWithRetryAsync<TResult>
    public static async Task<TResult> ExecuteInSavepointWithRetryAsync<TResult>(this IUnitOfWork unitOfWork, ResiliencePipeline pipeline, Func<IUnitOfWork, CancellationToken, Task<TResult>> operation, string? savepointName = null, CancellationToken cancellationToken = default)

    Executes an asynchronous operation that returns a value inside a database savepoint using the specified resilience pipeline.

    unitOfWork: this IUnitOfWork
    The unit of work managing the active database transaction.
    pipeline: ResiliencePipeline
    The resilience pipeline used to execute the retry strategy.
    operation: Func<IUnitOfWork, CancellationToken, Task<TResult>>
    The asynchronous operation returning a value to execute within the savepoint scope.
    savepointName: string?
    The optional custom savepoint name. If `null`, a unique name is generated automatically.
    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 returned by `operation`.

    Type parameters: TResult: The type of the result returned by the operation. Exceptions: ArgumentNullException: `unitOfWork`, `pipeline`, or `operation` is `null`

class

SqlResilienceDefaults

Ensamblado: EricksonLopez.DapperExtensions
public static class SqlResilienceDefaults

Provides factory methods for creating pre-configured database resilience pipelines.

Notas:

All pipelines follow the principle that the resilience pipeline must wrap the entire transactional unit (BeginUnitOfWork → Execute → Commit). Never retry individual statements inside an open transaction.

Miembros (30)

  • methodAggressive
    public static ResiliencePipeline Aggressive(ISqlTransientErrorDetector detector, TimeProvider? timeProvider = null)

    Creates an aggressive resilience pipeline optimized for high-availability scenarios.

    detector: ISqlTransientErrorDetector
    The transient error detector used to evaluate database exceptions.
    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: A `ResiliencePipeline` configured with: - 5 retry attempts with exponential backoff (500ms → 1s → 2s → 4s → 8s) and jitter - 60-second total timeout

    Exceptions: ArgumentNullException: `detector` is `null`

  • methodAggressivePipeline
    public static IResiliencePipeline AggressivePipeline(ISqlTransientErrorDetector detector, string pipelineName = "", TimeProvider? timeProvider = null)

    Creates an aggressive `IResiliencePipeline` optimized for high-availability scenarios.

    detector: ISqlTransientErrorDetector
    The transient error detector used to evaluate database exceptions.
    pipelineName: string
    The logical name assigned to the pipeline instance.
    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: An `IResiliencePipeline` wrapping the aggressive Polly pipeline.

    Exceptions: ArgumentNullException: `detector` is `null`

  • methodConservative
    public static ResiliencePipeline Conservative(ISqlTransientErrorDetector detector, TimeProvider? timeProvider = null)

    Creates a conservative resilience pipeline designed for workloads where retries are costly.

    detector: ISqlTransientErrorDetector
    The transient error detector used to evaluate database exceptions.
    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: A `ResiliencePipeline` configured with: - 1 retry attempt after a 5-second wait - 120-second total timeout

    Exceptions: ArgumentNullException: `detector` is `null`

  • methodConservativePipeline
    public static IResiliencePipeline ConservativePipeline(ISqlTransientErrorDetector detector, string pipelineName = "", TimeProvider? timeProvider = null)

    Creates a conservative `IResiliencePipeline` for workloads where retries are costly.

    detector: ISqlTransientErrorDetector
    The transient error detector used to evaluate database exceptions.
    pipelineName: string
    The logical name assigned to the pipeline instance.
    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: An `IResiliencePipeline` wrapping the conservative Polly pipeline.

    Exceptions: ArgumentNullException: `detector` is `null`

  • methodForMySql
    public static ResiliencePipeline ForMySql(TimeProvider? timeProvider = null)

    Creates a standard resilience pipeline pre-configured for MySQL and MariaDB transient errors.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: A `ResiliencePipeline` pre-configured for MySQL.

  • methodForMySqlPipeline
    public static IResiliencePipeline ForMySqlPipeline(TimeProvider? timeProvider = null)

    Creates a standard `IResiliencePipeline` pre-configured for MySQL.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: An `IResiliencePipeline` configured for MySQL operations.

  • methodForMySqlWithCircuitBreaker
    public static ResiliencePipeline ForMySqlWithCircuitBreaker(TimeProvider? timeProvider = null)

    Creates a standard resilience pipeline with circuit breaker pre-configured for MySQL and MariaDB.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: A `ResiliencePipeline` with circuit breaker pre-configured for MySQL.

  • methodForMySqlWithCircuitBreakerPipeline
    public static IResiliencePipeline ForMySqlWithCircuitBreakerPipeline(TimeProvider? timeProvider = null)

    Creates a standard `IResiliencePipeline` with circuit breaker for MySQL.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: An `IResiliencePipeline` with circuit breaker configured for MySQL operations.

  • methodForOracle
    public static ResiliencePipeline ForOracle(TimeProvider? timeProvider = null)

    Creates a standard resilience pipeline pre-configured for Oracle Database transient errors.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: A `ResiliencePipeline` pre-configured for Oracle Database.

  • methodForOraclePipeline
    public static IResiliencePipeline ForOraclePipeline(TimeProvider? timeProvider = null)

    Creates a standard `IResiliencePipeline` pre-configured for Oracle Database.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: An `IResiliencePipeline` configured for Oracle Database operations.

  • methodForOracleWithCircuitBreaker
    public static ResiliencePipeline ForOracleWithCircuitBreaker(TimeProvider? timeProvider = null)

    Creates a standard resilience pipeline with circuit breaker pre-configured for Oracle Database.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: A `ResiliencePipeline` with circuit breaker pre-configured for Oracle Database.

  • methodForOracleWithCircuitBreakerPipeline
    public static IResiliencePipeline ForOracleWithCircuitBreakerPipeline(TimeProvider? timeProvider = null)

    Creates a standard `IResiliencePipeline` with circuit breaker for Oracle Database.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: An `IResiliencePipeline` with circuit breaker configured for Oracle Database operations.

  • methodForPostgreSql
    public static ResiliencePipeline ForPostgreSql(TimeProvider? timeProvider = null)

    Creates a standard resilience pipeline pre-configured for PostgreSQL and CockroachDB transient errors.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: A `ResiliencePipeline` pre-configured for PostgreSQL.

  • methodForPostgreSqlPipeline
    public static IResiliencePipeline ForPostgreSqlPipeline(TimeProvider? timeProvider = null)

    Creates a standard `IResiliencePipeline` pre-configured for PostgreSQL.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: An `IResiliencePipeline` configured for PostgreSQL operations.

  • methodForPostgreSqlWithCircuitBreaker
    public static ResiliencePipeline ForPostgreSqlWithCircuitBreaker(TimeProvider? timeProvider = null)

    Creates a standard resilience pipeline with circuit breaker pre-configured for PostgreSQL and CockroachDB.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: A `ResiliencePipeline` with circuit breaker pre-configured for PostgreSQL.

  • methodForPostgreSqlWithCircuitBreakerPipeline
    public static IResiliencePipeline ForPostgreSqlWithCircuitBreakerPipeline(TimeProvider? timeProvider = null)

    Creates a standard `IResiliencePipeline` with circuit breaker for PostgreSQL.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: An `IResiliencePipeline` with circuit breaker configured for PostgreSQL operations.

  • methodForSqlServer
    public static ResiliencePipeline ForSqlServer(TimeProvider? timeProvider = null)

    Creates a standard resilience pipeline pre-configured for Microsoft SQL Server and Azure SQL transient errors.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: A `ResiliencePipeline` pre-configured for SQL Server.

  • methodForSqlServerPipeline
    public static IResiliencePipeline ForSqlServerPipeline(TimeProvider? timeProvider = null)

    Creates a standard `IResiliencePipeline` pre-configured for SQL Server.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: An `IResiliencePipeline` configured for SQL Server operations.

  • methodForSqlServerWithCircuitBreaker
    public static ResiliencePipeline ForSqlServerWithCircuitBreaker(TimeProvider? timeProvider = null)

    Creates a standard resilience pipeline with circuit breaker pre-configured for Microsoft SQL Server and Azure SQL.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: A `ResiliencePipeline` with circuit breaker pre-configured for SQL Server.

  • methodForSqlServerWithCircuitBreakerPipeline
    public static IResiliencePipeline ForSqlServerWithCircuitBreakerPipeline(TimeProvider? timeProvider = null)

    Creates a standard `IResiliencePipeline` with circuit breaker for SQL Server.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: An `IResiliencePipeline` with circuit breaker configured for SQL Server operations.

  • methodForSqlite
    public static ResiliencePipeline ForSqlite(TimeProvider? timeProvider = null)

    Creates a standard resilience pipeline pre-configured for SQLite transient errors.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: A `ResiliencePipeline` pre-configured for SQLite.

  • methodForSqlitePipeline
    public static IResiliencePipeline ForSqlitePipeline(TimeProvider? timeProvider = null)

    Creates a standard `IResiliencePipeline` pre-configured for SQLite.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: An `IResiliencePipeline` configured for SQLite operations.

  • methodForSqliteWithCircuitBreaker
    public static ResiliencePipeline ForSqliteWithCircuitBreaker(TimeProvider? timeProvider = null)

    Creates a standard resilience pipeline with circuit breaker pre-configured for SQLite.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: A `ResiliencePipeline` with circuit breaker pre-configured for SQLite.

  • methodForSqliteWithCircuitBreakerPipeline
    public static IResiliencePipeline ForSqliteWithCircuitBreakerPipeline(TimeProvider? timeProvider = null)

    Creates a standard `IResiliencePipeline` with circuit breaker for SQLite.

    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: An `IResiliencePipeline` with circuit breaker configured for SQLite operations.

  • methodStandard
    public static ResiliencePipeline Standard(ISqlTransientErrorDetector detector, TimeProvider? timeProvider = null)

    Creates a standard resilience pipeline configured with retry and timeout strategies.

    detector: ISqlTransientErrorDetector
    The transient error detector used to evaluate database exceptions.
    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: A `ResiliencePipeline` configured with: - 3 retry attempts with exponential backoff (1s → 2s → 4s) and jitter - 30-second total timeout

    This method returns a `Polly.ResiliencePipeline` (the low-level Polly v8 type). Per ADR-017, the canonical ecosystem API returns `EricksonLopez.Resilience.IResiliencePipeline`. Use the `For*Pipeline()` factory methods (e.g., `ForPostgreSqlPipeline()`, `ForSqlServerPipeline()`) to obtain the canonical `IResiliencePipeline` wrappers. The `ResiliencePipeline` overloads are retained as first-class compatibility APIs and are not marked `[Obsolete]`. See ADR-017. Exceptions: ArgumentNullException: `detector` is `null`

  • methodStandard<T>
    public static ResiliencePipeline<T> Standard<T>(ISqlTransientErrorDetector detector, TimeProvider? timeProvider = null)

    Creates a typed resilience pipeline configured with retry and timeout strategies.

    detector: ISqlTransientErrorDetector
    The transient error detector used to evaluate database exceptions.
    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: A `ResiliencePipeline<T>` configured with retry and timeout settings.

    Type parameters: T: The result type produced by operations executed through the pipeline. Exceptions: ArgumentNullException: `detector` is `null`

  • methodStandardPipeline
    public static IResiliencePipeline StandardPipeline(ISqlTransientErrorDetector detector, string pipelineName = "", TimeProvider? timeProvider = null)

    Creates a standard `IResiliencePipeline` configured with retry and timeout strategies.

    detector: ISqlTransientErrorDetector
    The transient error detector used to evaluate database exceptions.
    pipelineName: string
    The logical name assigned to the pipeline instance.
    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: An `IResiliencePipeline` wrapping the standard Polly pipeline.

    Exceptions: ArgumentNullException: `detector` is `null`

  • methodStandardWithCircuitBreaker
    public static ResiliencePipeline StandardWithCircuitBreaker(ISqlTransientErrorDetector detector, double failureRatio = 0.5, TimeSpan? samplingDuration = null, int minimumThroughput = 10, TimeSpan? breakDuration = null, TimeProvider? timeProvider = null)

    Creates a resilience pipeline combining retry, circuit breaker, and timeout strategies to protect against cascading database outages.

    detector: ISqlTransientErrorDetector
    The transient error detector used to evaluate database exceptions.
    failureRatio: double
    The failure ratio (from 0.0 to 1.0) that causes the circuit to open. Defaults to 0.5.
    samplingDuration: TimeSpan?
    The time window over which failure ratios are evaluated. Defaults to 10 seconds.
    minimumThroughput: int
    The minimum throughput required within the sampling window before the circuit evaluates. Defaults to 10.
    breakDuration: TimeSpan?
    The duration the circuit remains open before transitioning to a half-open state. Defaults to 30 seconds.
    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: A `ResiliencePipeline` configured with timeout, retry, and circuit breaker.

    Exceptions: ArgumentNullException: `detector` is `null`

  • methodStandardWithCircuitBreaker<T>
    public static ResiliencePipeline<T> StandardWithCircuitBreaker<T>(ISqlTransientErrorDetector detector, double failureRatio = 0.5, TimeSpan? samplingDuration = null, int minimumThroughput = 10, TimeSpan? breakDuration = null, TimeProvider? timeProvider = null)

    Creates a typed resilience pipeline combining retry, circuit breaker, and timeout strategies.

    detector: ISqlTransientErrorDetector
    The transient error detector used to evaluate database exceptions.
    failureRatio: double
    The failure ratio (from 0.0 to 1.0) that causes the circuit to open. Defaults to 0.5.
    samplingDuration: TimeSpan?
    The time window over which failure ratios are evaluated. Defaults to 10 seconds.
    minimumThroughput: int
    The minimum throughput required within the sampling window before the circuit evaluates. Defaults to 10.
    breakDuration: TimeSpan?
    The duration the circuit remains open before transitioning to a half-open state. Defaults to 30 seconds.
    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: A `ResiliencePipeline<T>` configured with retry, circuit breaker, and timeout settings.

    Type parameters: T: The result type produced by operations executed through the pipeline. Exceptions: ArgumentNullException: `detector` is `null`

  • methodStandardWithCircuitBreakerPipeline
    public static IResiliencePipeline StandardWithCircuitBreakerPipeline(ISqlTransientErrorDetector detector, string pipelineName = "", double failureRatio = 0.5, TimeSpan? samplingDuration = null, int minimumThroughput = 10, TimeSpan? breakDuration = null, TimeProvider? timeProvider = null)

    Creates a standard `IResiliencePipeline` with circuit breaker.

    detector: ISqlTransientErrorDetector
    The transient error detector used to evaluate database exceptions.
    pipelineName: string
    The logical name assigned to the pipeline instance.
    failureRatio: double
    The failure ratio (from 0.0 to 1.0) that causes the circuit to open. Defaults to 0.5.
    samplingDuration: TimeSpan?
    The time window over which failure ratios are evaluated. Defaults to 10 seconds.
    minimumThroughput: int
    The minimum throughput required within the sampling window. Defaults to 10.
    breakDuration: TimeSpan?
    The duration the circuit remains open before transitioning to half-open. Defaults to 30 seconds.
    timeProvider: TimeProvider?
    The optional custom time provider for testing and time virtualization.

    Retorna: An `IResiliencePipeline` wrapping the circuit-breaker pipeline.

    Exceptions: ArgumentNullException: `detector` is `null`

class

SqlResilienceExtensions

Ensamblado: EricksonLopez.DapperExtensions
public static class SqlResilienceExtensions

Provides extension methods for `IDbConnection` that execute SQL queries and commands through resilience pipelines.

Notas:

Critical rule: Resilience pipelines must wrap the entire transactional unit — never individual statements inside an open transaction. Architecture: Overloads accepting `IResiliencePipeline` are the canonical API aligned with the EricksonLopez.Resilience ecosystem. See ADR-017.

Miembros (14)

  • methodExecuteScalarWithResilienceAsync<T>
    public static async Task<T?> ExecuteScalarWithResilienceAsync<T>(this IDbConnection connection, SqlResult query, IResiliencePipeline pipeline, IDbTransaction? transaction = null, CancellationToken cancellationToken = default)

    Executes a compiled SQL query through the specified `IResiliencePipeline` and returns the first column of the first row.

    connection: this IDbConnection
    The database connection to execute the query on.
    query: SqlResult
    The compiled SQL query containing the SQL text and parameters.
    pipeline: IResiliencePipeline
    The resilience pipeline used to execute the query.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    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 of type `T`, or `default` if the result is null.

    Type parameters: T: The scalar return type. Exceptions: ArgumentNullException: `connection` or `pipeline` is `null`

  • methodExecuteScalarWithResilienceAsync<T>
    public static Task<T?> ExecuteScalarWithResilienceAsync<T>(this IDbConnection connection, SqlResult query, ResiliencePipeline pipeline, IDbTransaction? transaction = null, CancellationToken cancellationToken = default)

    Executes a compiled SQL query through the specified resilience pipeline and returns the first column of the first row.

    connection: this IDbConnection
    The database connection to execute the query on.
    query: SqlResult
    The compiled SQL query containing the SQL text and parameters.
    pipeline: ResiliencePipeline
    The resilience pipeline used to execute the query.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    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 of type `T`, or `default` if the result is null.

    Type parameters: T: The scalar return type. Exceptions: ArgumentNullException: `connection` or `pipeline` is `null`

  • methodExecuteWithResilienceAsync
    public static async Task<int> ExecuteWithResilienceAsync(this IDbConnection connection, SqlResult query, IResiliencePipeline pipeline, IDbTransaction? transaction = null, CancellationToken cancellationToken = default)

    Executes a compiled SQL command through the specified `IResiliencePipeline` and returns the number of affected rows.

    connection: this IDbConnection
    The database connection to execute the command on.
    query: SqlResult
    The compiled SQL query containing the SQL text and parameters.
    pipeline: IResiliencePipeline
    The resilience pipeline used to execute the command.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    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: `connection` or `pipeline` is `null`

  • methodExecuteWithResilienceAsync
    public static Task<int> ExecuteWithResilienceAsync(this IDbConnection connection, SqlResult query, ResiliencePipeline pipeline, IDbTransaction? transaction = null, CancellationToken cancellationToken = default)

    Executes a compiled SQL command through the specified resilience pipeline and returns the number of affected rows.

    connection: this IDbConnection
    The database connection to execute the command on.
    query: SqlResult
    The compiled SQL query containing the SQL text and parameters.
    pipeline: ResiliencePipeline
    The resilience pipeline used to execute the command.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    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: `connection` or `pipeline` is `null`

  • methodQueryFirstOrDefaultWithResilienceAsync<T>
    public static async Task<T?> QueryFirstOrDefaultWithResilienceAsync<T>(this IDbConnection connection, SqlResult query, IResiliencePipeline pipeline, IDbTransaction? transaction = null, CancellationToken cancellationToken = default)

    Executes a compiled SQL query through the specified `IResiliencePipeline` and returns the first element, or a default value if no element is found.

    connection: this IDbConnection
    The database connection to execute the query on.
    query: SqlResult
    The compiled SQL query containing the SQL text and parameters.
    pipeline: IResiliencePipeline
    The resilience pipeline used to execute the query.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    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 `T` instance, or `default` if no elements are found.

    Type parameters: T: The target entity type to map the row to. Exceptions: ArgumentNullException: `connection` or `pipeline` is `null`

  • methodQueryFirstOrDefaultWithResilienceAsync<T>
    public static Task<T?> QueryFirstOrDefaultWithResilienceAsync<T>(this IDbConnection connection, SqlResult query, ResiliencePipeline pipeline, IDbTransaction? transaction = null, CancellationToken cancellationToken = default)

    Executes a compiled SQL query through the specified resilience pipeline and returns the first element, or a default value if no element is found.

    connection: this IDbConnection
    The database connection to execute the query on.
    query: SqlResult
    The compiled SQL query containing the SQL text and parameters.
    pipeline: ResiliencePipeline
    The resilience pipeline used to execute the query.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    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 `T` instance, or `default` if no elements are found.

    Type parameters: T: The target entity type to map the row to. Exceptions: ArgumentNullException: `connection` or `pipeline` is `null`

  • methodQueryFirstWithResilienceAsync<T>
    public static async Task<T> QueryFirstWithResilienceAsync<T>(this IDbConnection connection, SqlResult query, IResiliencePipeline pipeline, IDbTransaction? transaction = null, CancellationToken cancellationToken = default)

    Executes a compiled SQL query through the specified `IResiliencePipeline` and returns the first matching element.

    connection: this IDbConnection
    The database connection to execute the query on.
    query: SqlResult
    The compiled SQL query containing the SQL text and parameters.
    pipeline: IResiliencePipeline
    The resilience pipeline used to execute the query.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    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 `T` instance.

    Type parameters: T: The target entity type to map the row to. Exceptions: ArgumentNullException: `connection` or `pipeline` is `null`

  • methodQueryFirstWithResilienceAsync<T>
    public static Task<T> QueryFirstWithResilienceAsync<T>(this IDbConnection connection, SqlResult query, ResiliencePipeline pipeline, IDbTransaction? transaction = null, CancellationToken cancellationToken = default)

    Executes a compiled SQL query through the specified resilience pipeline and returns the first matching element.

    connection: this IDbConnection
    The database connection to execute the query on.
    query: SqlResult
    The compiled SQL query containing the SQL text and parameters.
    pipeline: ResiliencePipeline
    The resilience pipeline used to execute the query.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    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 `T` instance.

    Type parameters: T: The target entity type to map the row to. Exceptions: ArgumentNullException: `connection` or `pipeline` is `null`

  • methodQuerySingleOrDefaultWithResilienceAsync<T>
    public static async Task<T?> QuerySingleOrDefaultWithResilienceAsync<T>(this IDbConnection connection, SqlResult query, IResiliencePipeline pipeline, IDbTransaction? transaction = null, CancellationToken cancellationToken = default)

    Executes a compiled SQL query through the specified `IResiliencePipeline` and returns a single element, or a default value if no element is found.

    connection: this IDbConnection
    The database connection to execute the query on.
    query: SqlResult
    The compiled SQL query containing the SQL text and parameters.
    pipeline: IResiliencePipeline
    The resilience pipeline used to execute the query.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    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 `T` instance, or `default` if no elements are found.

    Type parameters: T: The target entity type to map the row to. Exceptions: ArgumentNullException: `connection` or `pipeline` is `null`

  • methodQuerySingleOrDefaultWithResilienceAsync<T>
    public static Task<T?> QuerySingleOrDefaultWithResilienceAsync<T>(this IDbConnection connection, SqlResult query, ResiliencePipeline pipeline, IDbTransaction? transaction = null, CancellationToken cancellationToken = default)

    Executes a compiled SQL query through the specified resilience pipeline and returns a single element, or a default value if no element is found.

    connection: this IDbConnection
    The database connection to execute the query on.
    query: SqlResult
    The compiled SQL query containing the SQL text and parameters.
    pipeline: ResiliencePipeline
    The resilience pipeline used to execute the query.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    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 `T` instance, or `default` if no elements are found.

    Type parameters: T: The target entity type to map the row to. Exceptions: ArgumentNullException: `connection` or `pipeline` is `null`

  • methodQuerySingleWithResilienceAsync<T>
    public static async Task<T> QuerySingleWithResilienceAsync<T>(this IDbConnection connection, SqlResult query, IResiliencePipeline pipeline, IDbTransaction? transaction = null, CancellationToken cancellationToken = default)

    Executes a compiled SQL query through the specified `IResiliencePipeline` and returns exactly one matching element.

    connection: this IDbConnection
    The database connection to execute the query on.
    query: SqlResult
    The compiled SQL query containing the SQL text and parameters.
    pipeline: IResiliencePipeline
    The resilience pipeline used to execute the query.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    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 `T` instance.

    Type parameters: T: The target entity type to map the row to. Exceptions: ArgumentNullException: `connection` or `pipeline` is `null`

  • methodQuerySingleWithResilienceAsync<T>
    public static Task<T> QuerySingleWithResilienceAsync<T>(this IDbConnection connection, SqlResult query, ResiliencePipeline pipeline, IDbTransaction? transaction = null, CancellationToken cancellationToken = default)

    Executes a compiled SQL query through the specified resilience pipeline and returns exactly one matching element.

    connection: this IDbConnection
    The database connection to execute the query on.
    query: SqlResult
    The compiled SQL query containing the SQL text and parameters.
    pipeline: ResiliencePipeline
    The resilience pipeline used to execute the query.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    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 `T` instance.

    Type parameters: T: The target entity type to map the row to. Exceptions: ArgumentNullException: `connection` or `pipeline` is `null`

  • methodQueryWithResilienceAsync<T>
    public static async Task<IEnumerable<T>> QueryWithResilienceAsync<T>(this IDbConnection connection, SqlResult query, IResiliencePipeline pipeline, IDbTransaction? transaction = null, CancellationToken cancellationToken = default)

    Executes a compiled SQL query through the specified `IResiliencePipeline` and returns a sequence of mapped results.

    connection: this IDbConnection
    The database connection to execute the query on.
    query: SqlResult
    The compiled SQL query containing the SQL text and parameters.
    pipeline: IResiliencePipeline
    The resilience pipeline used to execute the query.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    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 sequence of mapped `T` instances.

    Type parameters: T: The target entity type to map each row to. Exceptions: ArgumentNullException: `connection` or `pipeline` is `null`

  • methodQueryWithResilienceAsync<T>
    public static Task<IEnumerable<T>> QueryWithResilienceAsync<T>(this IDbConnection connection, SqlResult query, ResiliencePipeline pipeline, IDbTransaction? transaction = null, CancellationToken cancellationToken = default)

    Executes a compiled SQL query through the specified resilience pipeline and returns a sequence of mapped results.

    connection: this IDbConnection
    The database connection to execute the query on.
    query: SqlResult
    The compiled SQL query containing the SQL text and parameters.
    pipeline: ResiliencePipeline
    The resilience pipeline used to execute the query.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    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 sequence of mapped `T` instances.

    Type parameters: T: The target entity type to map each row to. Exceptions: ArgumentNullException: `connection` or `pipeline` is `null`

class

SqlServerTransientErrorDetector

Ensamblado: EricksonLopez.DapperExtensions
public sealed class SqlServerTransientErrorDetector : ISqlTransientErrorDetector
Implementa: ISqlTransientErrorDetector

Provides transient error detection for Microsoft SQL Server databases.

Notas:

Transient error codes per Microsoft documentation: - 1205 — Deadlock victim - 1222 — Lock timeout exceeded - 233 — Connection initialization error - 64 — Connection terminated during handshake - 4060 — Database not available (AlwaysOn failover) - 40143 — Service encountered a transient error - 40197 — Service error (retry shortly) - 40501 — Service busy (retry in 10 seconds) - 40613 — Database not currently available - 49918 — Cannot process request (not enough resources)

Miembros (2)

  • methodIsTransient
    public bool IsTransient(Exception exception)

    Determines whether the specified exception represents a transient database error.

    exception: Exception
    The exception to evaluate.

    Retorna: `true` if the error is transient and the operation can be retried; otherwise, `false`.

  • propertyDefault
    public static SqlServerTransientErrorDetector Default { get; }

    Gets the default singleton instance of the `SqlServerTransientErrorDetector` class.

class

SqliteTransientErrorDetector

Ensamblado: EricksonLopez.DapperExtensions
public sealed class SqliteTransientErrorDetector : ISqlTransientErrorDetector
Implementa: ISqlTransientErrorDetector

Provides transient error detection for SQLite databases.

Notas:

SQLite uses numeric primary and extended error codes. Transient codes include: - 5 — SQLITE_BUSY: The database file is locked by another connection. - 6 — SQLITE_LOCKED: A table in the database is locked. - 261 — SQLITE_BUSY_RECOVERY: Another connection is recovering the WAL file. - 262 — SQLITE_LOCKED_SHAREDCACHE: Conflict in a shared cache. - 517 — SQLITE_BUSY_SNAPSHOT: Cannot promote read transaction to write transaction. - 773 — SQLITE_BUSY_TIMEOUT: Busy handler timeout expired. For connections using `Microsoft.Data.Sqlite`, the numeric error codes are exposed via the `SqliteException.SqliteErrorCode` and `SqliteException.SqliteExtendedErrorCode` properties, accessed via cached reflection to avoid a hard package dependency in the core assembly.

Miembros (2)

  • methodIsTransient
    public bool IsTransient(Exception exception)

    Determines whether the specified exception represents a transient database error.

    exception: Exception
    The exception to evaluate.

    Retorna: `true` if the error is transient and the operation can be retried; otherwise, `false`.

  • propertyDefault
    public static SqliteTransientErrorDetector Default { get; }

    Gets the default singleton instance of the `SqliteTransientErrorDetector` class.

EricksonLopez.DapperExtensions.SourceGenerators#

1
class

SqlEntityGenerator

Ensamblado: EricksonLopez.DapperExtensions.SourceGenerators
public class SqlEntityGenerator : IIncrementalGenerator
Implementa: IIncrementalGenerator

Generates zero-reflection Native AOT reader mappers for types decorated with the `SqlEntityAttribute`.

Miembros (2)

  • methodInitialize
    public void Initialize(IncrementalGeneratorInitializationContext context)

    Inherits documentation from base type or interface.

    context: IncrementalGeneratorInitializationContext
  • methodIsSyntaxTargetForGeneration
    public static bool IsSyntaxTargetForGeneration(SyntaxNode node)

    Determines whether a syntax node is a candidate for source generation.

    node: SyntaxNode
    The syntax node to inspect.

    Retorna: `true` if the node is a type declaration with attributes; otherwise, `false`.

EricksonLopez.DapperExtensions.SqlServer.Bulk#

3
class

BulkDataTableBuilder

Ensamblado: EricksonLopez.DapperExtensions.SqlServer
public static class BulkDataTableBuilder

Provides factory methods for creating `BulkDataTableBuilder<T>` instances.

Miembros (1)

  • methodFrom<T>
    public static BulkDataTableBuilder<T> From<T>(IEnumerable<T> items)

    Begins building a bulk `DataTable` for the specified collection.

    items: IEnumerable<T>
    The collection of entities to insert.

    Retorna: A new `BulkDataTableBuilder<T>` instance.

    Type parameters: T: The entity type to bulk-insert. Exceptions: ArgumentNullException: `items` is `null`

class

BulkDataTableBuilder<T>

Ensamblado: EricksonLopez.DapperExtensions.SqlServer
public sealed class BulkDataTableBuilder<T>

Builds a `DataTable` populated from an entity collection for high-performance `SqlBulkCopy` operations.

Notas:

Type parameters: T: The entity type to bulk-insert.

Miembros (3)

  • methodBuild
    public DataTable Build()

    Builds a `DataTable` pre-populated with rows from the entity collection.

    Retorna: A `DataTable` populated with column schemas and item row values.

    Exceptions: InvalidOperationException: No columns have been registered via Column()

  • methodColumn<TValue>
    public BulkDataTableBuilder<T> Column<TValue>(string columnName, Func<T, TValue> selector)

    Adds a column mapping with an extracted strongly-typed value to the table schema.

    columnName: string
    The column name in the target SQL Server table.
    selector: Func<T, TValue>
    The delegate that extracts the column value from each entity item.

    Retorna: The current builder instance.

    Type parameters: TValue: The CLR type of the column value. Exceptions: ArgumentException: `columnName` is empty or whitespace; ArgumentNullException: `selector` is `null`

  • propertyCount
    public int Count { get; }

    Gets the number of items to be inserted.

class

BulkExtensions

Ensamblado: EricksonLopez.DapperExtensions.SqlServer
public static class BulkExtensions

Provides extension methods for bulk INSERT, UPDATE, and DELETE operations on SQL Server connections.

Miembros (3)

  • methodBulkDeleteAsync
    public static async Task<int> BulkDeleteAsync(this DbConnection connection, string sql, object? param = null, DbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk DELETE operation on SQL Server using parameterized criteria or Table-Valued Parameters.

    connection: this DbConnection
    The database connection to execute the command on.
    sql: string
    The SQL DELETE statement.
    param: object?
    The optional command parameters.
    transaction: DbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` is `null`; ArgumentException: `sql` is empty or whitespace

  • methodBulkInsertAsync
    public static Task<int> BulkInsertAsync(this DbConnection connection, string destinationTableName, DataTable dataTable, DbTransaction? transaction = null, int batchSize = 0, int bulkCopyTimeout = 30, CancellationToken cancellationToken = default)

    Executes a high-throughput bulk INSERT into a SQL Server table using `SqlBulkCopy`.

    connection: this DbConnection
    The SQL Server database connection.
    destinationTableName: string
    The destination table name in the database.
    dataTable: DataTable
    The pre-populated `DataTable` containing row values to insert.
    transaction: DbTransaction?
    The optional transaction to execute within.
    batchSize: int
    The number of rows per batch, or 0 for a single batch.
    bulkCopyTimeout: int
    The timeout in seconds for the bulk copy operation.
    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 copied to the destination table.

    Exceptions: ArgumentNullException: `connection` or `dataTable` is `null`; ArgumentException: `destinationTableName` is empty or whitespace, or `connection` is not a `SqlConnection`

  • methodBulkUpdateAsync
    public static async Task<int> BulkUpdateAsync(this DbConnection connection, string sql, object? param = null, DbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk UPDATE operation on SQL Server using parameterized criteria or Table-Valued Parameters.

    connection: this DbConnection
    The database connection to execute the command on.
    sql: string
    The SQL UPDATE statement.
    param: object?
    The optional command parameters.
    transaction: DbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` is `null`; ArgumentException: `sql` is empty or whitespace

EricksonLopez.DapperExtensions.SqlServer.Pagination#

1
class

PagedQueryExtensions

Ensamblado: EricksonLopez.DapperExtensions.SqlServer
public static class PagedQueryExtensions

Provides extension methods for executing paginated queries with Dapper on SQL Server databases.

Miembros (3)

  • methodQueryCursorPagedAsync<T>
    public static async Task<ICursorPagedList<T>> QueryCursorPagedAsync<T>(this IDbConnection connection, string sql, string cursorColumn, CursorPaginationParameters parameters, Func<T, string> cursorSelector, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a cursor-based (keyset) paginated query returning a cursor paged list.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The base SQL query without keyset filters or ordering.
    cursorColumn: string
    The column name used as the pagination cursor.
    parameters: CursorPaginationParameters
    The cursor pagination parameters containing page boundaries.
    cursorSelector: Func<T, string>
    The delegate that extracts the cursor value from an entity item.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a cursor paged list of `T` items.

    Type parameters: T: The entity type to map each result row to. Exceptions: ArgumentNullException: `connection` or `cursorSelector` is `null`; ArgumentException: `sql` or `cursorColumn` is empty or whitespace

  • methodQueryPagedAsync<T>
    public static async Task<ICountedPagedList<T>> QueryPagedAsync<T>(this IDbConnection connection, string sql, string countSql, PaginationParameters pagination, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes an offset-based paginated query using separate data and total count SQL statements.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The SQL statement to retrieve page data without pagination clauses.
    countSql: string
    The SQL statement to calculate the total record count.
    pagination: PaginationParameters
    The pagination parameters including page number and page size.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a counted paged list of `T` items.

    Type parameters: T: The entity type to map each result row to. Exceptions: ArgumentNullException: `connection` is `null`; ArgumentException: `sql` or `countSql` is empty or whitespace

  • methodQueryPagedMultipleAsync<T>
    public static async Task<ICountedPagedList<T>> QueryPagedMultipleAsync<T>(this IDbConnection connection, string sql, PaginationParameters pagination, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes an offset-based paginated query using a single multi-result SQL statement.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The SQL query returning two result sets: the page items followed by the total count.
    pagination: PaginationParameters
    The pagination parameters including page number and page size.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a counted paged list of `T` items.

    Type parameters: T: The entity type to map each result row to. Exceptions: ArgumentNullException: `connection` is `null`; ArgumentException: `sql` is empty or whitespace

EricksonLopez.DapperExtensions.SqlServer.Transactions#

1
class

TransactionExtensions

Ensamblado: EricksonLopez.DapperExtensions.SqlServer
public static class TransactionExtensions

Provides extension methods for executing operations within a SQL Server transaction scope.

Miembros (2)

  • methodExecuteInTransactionAsync
    public static async Task ExecuteInTransactionAsync(this DbConnection connection, Func<DbTransaction, Task> operation, CancellationToken cancellationToken = default)

    Executes an asynchronous operation within a newly opened transaction, committing automatically on success and rolling back on failure.

    connection: this DbConnection
    The database connection to execute the transaction on.
    operation: Func<DbTransaction, Task>
    The asynchronous operation to execute within the active transaction.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

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

  • methodExecuteInTransactionAsync<TResult>
    public static async Task<TResult> ExecuteInTransactionAsync<TResult>(this DbConnection connection, Func<DbTransaction, Task<TResult>> operation, CancellationToken cancellationToken = default)

    Executes an asynchronous operation returning a result within a newly opened transaction, committing on success and rolling back on failure.

    connection: this DbConnection
    The database connection to execute the transaction on.
    operation: Func<DbTransaction, Task<TResult>>
    The asynchronous operation returning a result to execute within the active transaction.
    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 returned by `operation`.

    Type parameters: TResult: The type of the result returned by the operation. Exceptions: ArgumentNullException: `connection` or `operation` is `null`

EricksonLopez.DapperExtensions.SqlServer.TypeHandlers#

2
class

JsonTypeHandler<T>

Ensamblado: EricksonLopez.DapperExtensions.SqlServer
public sealed class JsonTypeHandler<T> : SqlMapper.TypeHandler<T>
Hereda de: SqlMapper.TypeHandler<T>

Provides a Dapper type handler for SQL Server JSON columns using System.Text.Json serialization.

Notas:

Type parameters: T: The .NET type to serialize and deserialize.

Miembros (2)

  • methodParse
    public override T? Parse(object value)

    Inherits documentation from base type or interface.

    value: object
  • methodSetValue
    public override void SetValue(IDbDataParameter parameter, T? value)

    Inherits documentation from base type or interface.

    parameter: IDbDataParameter
    value: T?
class

SqlServerTypeHandlerRegistrar

Ensamblado: EricksonLopez.DapperExtensions.SqlServer
public static class SqlServerTypeHandlerRegistrar

Provides convenience registration methods for SQL Server JSON type handlers.

Miembros (1)

  • methodRegisterJsonHandler<T>
    public static void RegisterJsonHandler<T>()

    Registers a JSON type handler for the specified type with Dapper.

    Type parameters: T: The .NET type to map to JSON columns.

EricksonLopez.DapperExtensions.Sqlite.Bulk#

3
class

BulkBuilder

Ensamblado: EricksonLopez.DapperExtensions.Sqlite
public static class BulkBuilder

Provides factory methods for creating `BulkBuilder<T>` instances.

Miembros (1)

  • methodFrom<T>
    public static BulkBuilder<T> From<T>(IEnumerable<T> items)

    Begins building a bulk INSERT operation for the specified collection.

    items: IEnumerable<T>
    The collection of entities to insert.

    Retorna: A new `BulkBuilder<T>` instance.

    Type parameters: T: The entity type to bulk-insert. Exceptions: ArgumentNullException: `items` is `null`

class

BulkBuilder<T>

Ensamblado: EricksonLopez.DapperExtensions.Sqlite
public sealed class BulkBuilder<T>

Builds parameterized multi-row INSERT SQL statements and Dapper parameters for bulk operations on SQLite.

Notas:

SQLite uses multi-row VALUES syntax: `INSERT INTO "table" ("col1", "col2") VALUES (@p0_0, @p0_1), (@p1_0, @p1_1), ...` Type parameters: T: The entity type to bulk-insert.

Miembros (7)

  • methodBatchSize
    public BulkBuilder<T> BatchSize(int maxRowsPerBatch)

    Sets the maximum number of rows per generated SQL batch.

    maxRowsPerBatch: int
    The maximum rows per batch (must be greater than zero).

    Retorna: The current builder instance.

    Exceptions: ArgumentOutOfRangeException: `maxRowsPerBatch` is less than or equal to zero

  • methodBuild
    public (string? Sql, DynamicParameters? Parameters) Build()

    Builds the SQL INSERT statement and a `DynamicParameters` object containing all row values as named parameters. When the total parameter count exceeds `MaxParametersPerStatement`, safe parameter-bounded batches are registered for automatic chunked execution in `BulkExtensions.BulkInsertAsync(IDbConnection, string?, DynamicParameters?, IDbTransaction?, int?, CancellationToken)`.

    Retorna: A tuple containing the generated SQL text and parameter collection, or `(null, null)` if there are no items.

    Exceptions: InvalidOperationException: The destination table name or column mappings have not been configured

  • methodBuildBatches
    public IReadOnlyList<(string Sql, DynamicParameters Parameters)> BuildBatches()

    Builds one or more parameter-bounded SQL INSERT batches so large collections never exceed SQLite's parameter limit.

    Retorna: A read-only list of SQL and parameter batches.

    Exceptions: InvalidOperationException: The destination table name or column mappings have not been configured

  • methodColumn
    public BulkBuilder<T> Column(string columnName, Func<T, object?> selector)

    Adds a column mapping to the bulk INSERT operation.

    columnName: string
    The column name in the target table.
    selector: Func<T, object?>
    The delegate that extracts the column value from each entity item.

    Retorna: The current builder instance.

    Exceptions: ArgumentException: `columnName` is empty, whitespace, or contains null characters; ArgumentNullException: `selector` is `null`

  • methodTable
    public BulkBuilder<T> Table(string tableName)

    Sets the destination table name for the bulk INSERT operation.

    tableName: string
    The table name (or schema-qualified `schema.table`).

    Retorna: The current builder instance.

    Exceptions: ArgumentException: `tableName` is empty, whitespace, contains null characters, or has invalid schema segments

  • propertyCount
    public int Count { get; }

    Gets the number of items to be inserted.

  • fieldMaxParametersPerStatement
    public const int MaxParametersPerStatement

    Defines the maximum number of SQL parameters permitted in a single SQLite statement batch (SQLite limit is 32,766).

class

BulkExtensions

Ensamblado: EricksonLopez.DapperExtensions.Sqlite
public static class BulkExtensions

Provides extension methods for bulk INSERT, UPSERT, UPDATE, and DELETE operations on SQLite connections.

Miembros (5)

  • methodBulkDeleteAsync
    public static Task<int> BulkDeleteAsync(this IDbConnection connection, string? sql, DynamicParameters? parameters, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk DELETE statement using pre-built SQL and parameters.

    connection: this IDbConnection
    The database connection to execute the command on.
    sql: string?
    The bulk DELETE SQL statement.
    parameters: DynamicParameters?
    The parameterized values for the bulk operation.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` is `null`

  • methodBulkInsertAsync
    public static async Task<int> BulkInsertAsync(this IDbConnection connection, string? sql, DynamicParameters? parameters, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk INSERT statement using pre-built SQL and parameters.

    connection: this IDbConnection
    The database connection to execute the command on.
    sql: string?
    The multi-row INSERT SQL statement.
    parameters: DynamicParameters?
    The parameterized values for the bulk insert.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` is `null`

  • methodBulkInsertAsync<T>
    public static async Task<int> BulkInsertAsync<T>(this IDbConnection connection, BulkBuilder<T> builder, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk INSERT statement using a configured `BulkBuilder<T>`, automatically chunking into safe parameter-bounded batches when needed.

    connection: this IDbConnection
    The database connection to execute the command on.
    builder: BulkBuilder<T>
    The configured bulk builder.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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 total number of rows affected across all batches.

    Type parameters: T: The entity type to bulk-insert. Exceptions: ArgumentNullException: `connection` or `builder` is `null`

  • methodBulkUpdateAsync
    public static Task<int> BulkUpdateAsync(this IDbConnection connection, string? sql, DynamicParameters? parameters, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk UPDATE statement using pre-built SQL and parameters.

    connection: this IDbConnection
    The database connection to execute the command on.
    sql: string?
    The bulk UPDATE SQL statement.
    parameters: DynamicParameters?
    The parameterized values for the bulk operation.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` is `null`

  • methodBulkUpsertAsync
    public static Task<int> BulkUpsertAsync(this IDbConnection connection, string? sql, DynamicParameters? parameters, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a bulk INSERT ... ON CONFLICT DO UPDATE (upsert) statement using pre-built SQL and parameters.

    connection: this IDbConnection
    The database connection to execute the command on.
    sql: string?
    The multi-row UPSERT SQL statement.
    parameters: DynamicParameters?
    The parameterized values for the bulk operation.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    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: `connection` is `null`

EricksonLopez.DapperExtensions.Sqlite.Pagination#

1
class

PagedQueryExtensions

Ensamblado: EricksonLopez.DapperExtensions.Sqlite
public static class PagedQueryExtensions

Provides extension methods for executing paginated queries with Dapper on SQLite databases.

Miembros (3)

  • methodQueryCursorPagedAsync<T>
    public static async Task<ICursorPagedList<T>> QueryCursorPagedAsync<T>(this IDbConnection connection, string sql, string cursorColumn, CursorPaginationParameters parameters, Func<T, string> cursorSelector, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes a cursor-based (keyset) paginated query returning a cursor paged list.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The base SQL query without keyset filters or ordering.
    cursorColumn: string
    The column name used as the pagination cursor.
    parameters: CursorPaginationParameters
    The cursor pagination parameters containing page boundaries.
    cursorSelector: Func<T, string>
    The delegate that extracts the cursor value from an entity item.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a cursor paged list of `T` items.

    Type parameters: T: The entity type to map each result row to. Exceptions: ArgumentNullException: `connection` or `cursorSelector` is `null`; ArgumentException: `sql` or `cursorColumn` is empty or whitespace

  • methodQueryPagedAsync<T>
    public static async Task<ICountedPagedList<T>> QueryPagedAsync<T>(this IDbConnection connection, string sql, string countSql, PaginationParameters pagination, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes an offset-based paginated query using separate data and total count SQL statements.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The SQL statement to retrieve page data without pagination clauses.
    countSql: string
    The SQL statement to calculate the total record count.
    pagination: PaginationParameters
    The pagination parameters including page number and page size.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a counted paged list of `T` items.

    Type parameters: T: The entity type to map each result row to. Exceptions: ArgumentNullException: `connection` is `null`; ArgumentException: `sql` or `countSql` is empty or whitespace

  • methodQueryPagedMultipleAsync<T>
    public static async Task<ICountedPagedList<T>> QueryPagedMultipleAsync<T>(this IDbConnection connection, string sql, PaginationParameters pagination, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CancellationToken cancellationToken = default)

    Executes an offset-based paginated query using a single multi-result SQL statement.

    connection: this IDbConnection
    The database connection to execute the query on.
    sql: string
    The SQL query returning two result sets: the page items followed by the total count.
    pagination: PaginationParameters
    The pagination parameters including page number and page size.
    param: object?
    The optional query parameters.
    transaction: IDbTransaction?
    The optional transaction to execute within.
    commandTimeout: int?
    The optional command timeout in seconds.
    cancellationToken: CancellationToken
    A token to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation. The task result contains a counted paged list of `T` items.

    Type parameters: T: The entity type to map each result row to. Exceptions: ArgumentNullException: `connection` is `null`; ArgumentException: `sql` is empty or whitespace

EricksonLopez.DapperExtensions.Sqlite.Transactions#

1
class

TransactionExtensions

Ensamblado: EricksonLopez.DapperExtensions.Sqlite
public static class TransactionExtensions

Provides extension methods for executing operations within a SQLite transaction scope.

Miembros (2)

  • methodExecuteInTransactionAsync
    public static async Task ExecuteInTransactionAsync(this DbConnection connection, Func<DbTransaction, Task> operation, CancellationToken cancellationToken = default)

    Executes an asynchronous operation within a newly opened transaction, committing automatically on success and rolling back on failure.

    connection: this DbConnection
    The database connection to execute the transaction on.
    operation: Func<DbTransaction, Task>
    The asynchronous operation to execute within the active transaction.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

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

  • methodExecuteInTransactionAsync<TResult>
    public static async Task<TResult> ExecuteInTransactionAsync<TResult>(this DbConnection connection, Func<DbTransaction, Task<TResult>> operation, CancellationToken cancellationToken = default)

    Executes an asynchronous operation returning a result within a newly opened transaction, committing on success and rolling back on failure.

    connection: this DbConnection
    The database connection to execute the transaction on.
    operation: Func<DbTransaction, Task<TResult>>
    The asynchronous operation returning a result to execute within the active transaction.
    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 returned by `operation`.

    Type parameters: TResult: The type of the result returned by the operation. Exceptions: ArgumentNullException: `connection` or `operation` is `null`

EricksonLopez.DapperExtensions.Sqlite.TypeHandlers#

2
class

JsonTypeHandler<T>

Ensamblado: EricksonLopez.DapperExtensions.Sqlite
public sealed class JsonTypeHandler<T> : SqlMapper.TypeHandler<T>
Hereda de: SqlMapper.TypeHandler<T>

Provides a Dapper type handler for SQLite JSON columns using System.Text.Json serialization.

Notas:

Type parameters: T: The .NET type to serialize and deserialize.

Miembros (2)

  • methodParse
    public override T? Parse(object value)

    Inherits documentation from base type or interface.

    value: object
  • methodSetValue
    public override void SetValue(IDbDataParameter parameter, T? value)

    Inherits documentation from base type or interface.

    parameter: IDbDataParameter
    value: T?
class

SqliteTypeHandlerRegistrar

Ensamblado: EricksonLopez.DapperExtensions.Sqlite
public static class SqliteTypeHandlerRegistrar

Provides convenience registration methods for SQLite JSON type handlers.

Miembros (1)

  • methodRegisterJsonHandler<T>
    public static void RegisterJsonHandler<T>()

    Registers a JSON type handler for the specified type with Dapper.

    Type parameters: T: The .NET type to map to JSON columns.

EricksonLopez.DapperExtensions.Streaming#

1
class

DapperStreamingExtensions

Ensamblado: EricksonLopez.DapperExtensions
public static class DapperStreamingExtensions

Provides unbuffered, memory-efficient streaming extensions for Dapper queries returning `IAsyncEnumerable<T>`.

Notas:

Memory Profile O(1) for the streaming operation: Standard Dapper `QueryAsync<T>` buffers the entire result set into an in-memory list before returning. For large datasets (10K+ rows), this causes high LOH allocations and GC Gen 2 pressure. These extension methods stream rows one-by-one off the wire, keeping the streaming operation itself at O(1) memory. Note: if the caller accumulates results in a `List<T>` or similar collection, overall memory usage becomes O(N). These extension methods execute unbuffered queries using Dapper's row parsers, streaming rows sequentially off the wire and yielding each entity on-the-fly. The caller must consume the stream promptly. Exception propagation: Database provider exceptions (e.g., `NpgsqlException`, `SqlException`) thrown during reader execution or row reading propagate directly to the caller without being caught or wrapped. Native AOT limitation (ADR-006, ADR-019): `StreamAsync<T>` uses Dapper's `GetRowParser<T>()` internally, which is reflection-based. For fully AOT-safe streaming, use `MultiMapBuilder<T>` with `[SqlEntity]` source-generated parsers instead.

Miembros (2)

  • methodStreamAsync<T>
    public static IAsyncEnumerable<T> StreamAsync<T>(this IDbConnection connection, CommandDefinition command, CancellationToken cancellationToken = default)

    Streams rows one-by-one from the database connection using a `CommandDefinition` with unbuffered execution.

    connection: this IDbConnection
    The database connection.
    command: CommandDefinition
    The command definition specifying query parameters, timeout, and cancellation token.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: An asynchronous stream of `T` entities.

    Type parameters: T: The entity or projected type. Exceptions: ArgumentNullException: `connection` is `null`

  • methodStreamAsync<T>
    public static IAsyncEnumerable<T> StreamAsync<T>(this IDbConnection connection, string sql, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CommandType? commandType = null, CancellationToken cancellationToken = default)

    Streams rows one-by-one from the database connection without buffering the full result set into memory.

    connection: this IDbConnection
    The database connection. Must be open or capable of being opened.
    sql: string
    The SQL query text.
    param: object?
    Optional query parameters.
    transaction: IDbTransaction?
    Optional active database transaction.
    commandTimeout: int?
    Optional command timeout in seconds.
    commandType: CommandType?
    Optional command type (Text, StoredProcedure, TableDirect).
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: An asynchronous stream of `T` entities.

    Type parameters: T: The entity or projected type. Exceptions: ArgumentNullException: `connection` or `sql` is `null`

EricksonLopez.DapperExtensions.TypeHandlers#

4
class

DapperTypeHandlerRegistrar

Ensamblado: EricksonLopez.DapperExtensions
public static class DapperTypeHandlerRegistrar

Provides registration methods for standard Dapper type handlers.

Miembros (2)

  • methodRegisterStandardHandlers
    public static void RegisterStandardHandlers()

    Registers standard modern .NET type handlers (`DateOnly` and `TimeOnly`) with Dapper.

    Call once during application initialization before executing queries.

  • methodRegisterStringEnumHandler<TEnum>
    public static void RegisterStringEnumHandler<TEnum>() where TEnum : struct, Enum

    Registers a string-based enum handler for the specified enumeration type.

    Type parameters: TEnum: The enumeration type to map as strings.

class

DateOnlyTypeHandler

Ensamblado: EricksonLopez.DapperExtensions
public sealed class DateOnlyTypeHandler : SqlMapper.TypeHandler<DateOnly>
Hereda de: SqlMapper.TypeHandler<DateOnly>

Provides a Dapper type handler for mapping `DateOnly` values to and from database date and datetime columns.

Miembros (3)

  • methodParse
    public override DateOnly Parse(object value)

    Inherits documentation from base type or interface.

    value: object
  • methodSetValue
    public override void SetValue(IDbDataParameter parameter, DateOnly value)

    Inherits documentation from base type or interface.

    parameter: IDbDataParameter
    value: DateOnly

    Exceptions: ArgumentNullException: `parameter` is `null`

  • fieldDefault
    public static readonly DateOnlyTypeHandler Default

    Gets the default singleton instance of the `DateOnlyTypeHandler` class.

class

StringEnumTypeHandler<TEnum>

Ensamblado: EricksonLopez.DapperExtensions
public sealed class StringEnumTypeHandler<TEnum> : SqlMapper.TypeHandler<TEnum> where TEnum : struct, Enum
Hereda de: SqlMapper.TypeHandler<TEnum>

Provides a Dapper type handler for mapping enumeration values to and from string or varchar database columns.

Notas:

Type parameters: TEnum: The enumeration type to map.

Miembros (3)

  • methodParse
    public override TEnum Parse(object value)

    Inherits documentation from base type or interface.

    value: object
  • methodSetValue
    public override void SetValue(IDbDataParameter parameter, TEnum value)

    Inherits documentation from base type or interface.

    parameter: IDbDataParameter
    value: TEnum

    Exceptions: ArgumentNullException: `parameter` is `null`

  • fieldDefault
    public static readonly StringEnumTypeHandler<TEnum> Default

    Gets the default singleton instance of the `StringEnumTypeHandler<TEnum>` class.

class

TimeOnlyTypeHandler

Ensamblado: EricksonLopez.DapperExtensions
public sealed class TimeOnlyTypeHandler : SqlMapper.TypeHandler<TimeOnly>
Hereda de: SqlMapper.TypeHandler<TimeOnly>

Provides a Dapper type handler for mapping `TimeOnly` values to and from database time and timespan columns.

Miembros (3)

  • methodParse
    public override TimeOnly Parse(object value)

    Inherits documentation from base type or interface.

    value: object
  • methodSetValue
    public override void SetValue(IDbDataParameter parameter, TimeOnly value)

    Inherits documentation from base type or interface.

    parameter: IDbDataParameter
    value: TimeOnly

    Exceptions: ArgumentNullException: `parameter` is `null`

  • fieldDefault
    public static readonly TimeOnlyTypeHandler Default

    Gets the default singleton instance of the `TimeOnlyTypeHandler` class.

EricksonLopez.DapperExtensions.UnitOfWork#

3
interface

ISavepoint

Ensamblado: EricksonLopez.DapperExtensions
public interface ISavepoint

Represents a named savepoint within a database transaction, enabling partial rollbacks.

Miembros (3)

  • methodReleaseAsync
    Task ReleaseAsync(CancellationToken cancellationToken = default)

    Releases the savepoint, removing it from the active transaction.

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

    Retorna: A task representing the asynchronous operation.

  • methodRollbackAsync
    Task RollbackAsync(CancellationToken cancellationToken = default)

    Rolls back the database transaction to this savepoint.

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

    Retorna: A task representing the asynchronous operation.

  • propertyName
    string Name { get; }

    Gets the name of the savepoint.

interface

IUnitOfWork

Ensamblado: EricksonLopez.DapperExtensions
public interface IUnitOfWork : IAsyncDisposable
Implementa: IAsyncDisposable

Represents an active database Unit of Work that manages a transaction boundary across multiple operations.

Notas:

Architectural Role & Clean Architecture Boundary: `IUnitOfWork` represents the application/domain boundary contract expressing that a set of operations belongs to a single logical unit of work. Infrastructure-level transactional coordination (such as ambient `AsyncLocal` propagation, nested savepoints, enlistment hooks, and monadic auto-rollback) is managed by `ITransactionManager` in the `EricksonLopez.Transaction` package. If `CommitAsync` is not called before disposal, the transaction is automatically rolled back.

Miembros (5)

  • methodCommitAsync
    Task CommitAsync(CancellationToken cancellationToken = default)

    Commits all operations executed within this unit of work to the database.

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

    Retorna: A task representing the asynchronous operation.

    Exceptions: ObjectDisposedException: The unit of work has already been disposed

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

    Creates a named savepoint within the active transaction.

    name: string
    The name of 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 an `ISavepoint` instance.

    Savepoints require the underlying `Data.IDbTransaction` to be an instance of `Common.DbTransaction` (i.e., a real ADO.NET provider transaction). If the underlying transaction is not a `Common.DbTransaction` — for example, when using a custom mock or a non-standard in-memory `Data.IDbTransaction` implementation — a `NotSupportedException` is thrown. To test code that creates savepoints, use a real ADO.NET provider (e.g., SQLite in-memory via `Microsoft.Data.Sqlite`) or a test double that derives from `Common.DbTransaction`. Exceptions: ArgumentException: `name` is null, empty, or whitespace; NotSupportedException: The underlying transaction does not inherit from `Common.DbTransaction` and therefore does not support savepoints; ObjectDisposedException: The unit of work has already been disposed

  • methodRollbackAsync
    Task RollbackAsync(CancellationToken cancellationToken = default)

    Rolls back all operations executed within this unit of work.

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

    Retorna: A task representing the asynchronous operation.

    Exceptions: ObjectDisposedException: The unit of work has already been disposed

  • propertyIsolationLevel
    IsolationLevel IsolationLevel { get; }

    Gets the isolation level of the active transaction.

  • propertyTransaction
    IDbTransaction Transaction { get; }

    Gets the underlying database transaction.

class

UnitOfWorkExtensions

Ensamblado: EricksonLopez.DapperExtensions
public static class UnitOfWorkExtensions

Provides extension methods on `IDbConnection` for starting transactions encapsulated as an `IUnitOfWork`.

Miembros (4)

  • methodBeginUnitOfWorkAsync
    public static async Task<IUnitOfWork> BeginUnitOfWorkAsync(this DbConnection connection, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted, CancellationToken cancellationToken = default)

    Begins a new transaction wrapped in an `IUnitOfWork` using fully asynchronous methods on `DbConnection`.

    connection: this DbConnection
    The asynchronous database connection.
    isolationLevel: IsolationLevel
    The isolation level for the transaction. Defaults to `IsolationLevel.ReadCommitted`.
    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 active `IUnitOfWork`.

    Exceptions: ArgumentNullException: `connection` is `null`

  • methodBeginUnitOfWorkAsync
    public static async Task<IUnitOfWork> BeginUnitOfWorkAsync(this IDbConnection connection, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted, CancellationToken cancellationToken = default)

    Begins a new transaction wrapped in an `IUnitOfWork` with the specified isolation level.

    connection: this IDbConnection
    The database connection.
    isolationLevel: IsolationLevel
    The isolation level for the transaction. Defaults to `IsolationLevel.ReadCommitted`.
    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 active `IUnitOfWork`.

    Exceptions: ArgumentNullException: `connection` is `null`

  • methodWithUnitOfWorkAsync
    public static async Task WithUnitOfWorkAsync(this IDbConnection connection, Func<IUnitOfWork, CancellationToken, Task> action, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted, CancellationToken cancellationToken = default)

    Executes a transactional operation using a Unit of Work scope, committing automatically on success and rolling back on failure.

    connection: this IDbConnection
    The database connection to execute the operation on.
    action: Func<IUnitOfWork, CancellationToken, Task>
    The asynchronous operation to execute within the transaction scope.
    isolationLevel: IsolationLevel
    The isolation level for the transaction. Defaults to `IsolationLevel.ReadCommitted`.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Retorna: A task representing the asynchronous operation.

    Exceptions: ArgumentNullException: `connection` or `action` is `null`

  • methodWithUnitOfWorkAsync<TResult>
    public static async Task<TResult> WithUnitOfWorkAsync<TResult>(this IDbConnection connection, Func<IUnitOfWork, CancellationToken, Task<TResult>> action, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted, CancellationToken cancellationToken = default)

    Executes a transactional operation returning a result using a Unit of Work scope, committing automatically on success and rolling back on failure.

    connection: this IDbConnection
    The database connection to execute the operation on.
    action: Func<IUnitOfWork, CancellationToken, Task<TResult>>
    The asynchronous operation to execute within the transaction scope.
    isolationLevel: IsolationLevel
    The isolation level for the transaction. Defaults to `IsolationLevel.ReadCommitted`.
    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 returned by `action`.

    Type parameters: TResult: The type of the result returned by the operation. Exceptions: ArgumentNullException: `connection` or `action` 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.