Transformations.Dapper 2.0.4.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Transformations.Dapper --version 2.0.4.1
                    
NuGet\Install-Package Transformations.Dapper -Version 2.0.4.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Transformations.Dapper" Version="2.0.4.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Transformations.Dapper" Version="2.0.4.1" />
                    
Directory.Packages.props
<PackageReference Include="Transformations.Dapper" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Transformations.Dapper --version 2.0.4.1
                    
#r "nuget: Transformations.Dapper, 2.0.4.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Transformations.Dapper@2.0.4.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Transformations.Dapper&version=2.0.4.1
                    
Install as a Cake Addin
#tool nuget:?package=Transformations.Dapper&version=2.0.4.1
                    
Install as a Cake Tool

Transformations.Dapper

Resilient Dapper query wrappers with built-in transient SQL fault detection — drop-in replacements for standard Dapper methods that automatically retry on deadlocks, timeouts, and Azure SQL throttling.

NuGet .NET 8 | 9 | 10

📖 Overview

Transformations.Dapper brings the hardened retry semantics of Transformations.Core directly into your Dapper workflows. Cloud databases regularly drop connections or trigger transient deadlocks — this library automatically identifies retriable SQL error codes and re-executes queries transparently.

🚀 Why Transformations.Dapper?

Instead of manually catching SqlException and writing retry loops everywhere, you swap connection.QueryAsync for connection.QueryWithRetryAsync. The built-in transient fault detector handles the backoff strategy. The result is database code that's both cleaner and more resilient — with no extra ceremony.

📦 Install

<PackageReference Include="Transformations.Dapper" Version="2.0.4.1" />

💡 What's Included

Resilient Async Queries

Swap connection.QueryAsync for connection.QueryWithRetryAsync. Transient SQL faults are detected automatically and retried with exponential backoff.

// 3 retries, 500ms initial delay — doubles each attempt
var users = await connection.QueryWithRetryAsync<User>(
    "SELECT * FROM Users WHERE Status = @Status",
    new { Status = UserStatus.Active },
    retryCount: 3,
    initialDelay: TimeSpan.FromMilliseconds(500));

// Single row — returns null rather than throwing on no result
var user = await connection.QuerySingleOrDefaultWithRetryAsync<User>(
    "SELECT * FROM Users WHERE Id = @Id",
    new { Id = userId });

// Execute (INSERT/UPDATE/DELETE) and scalar
int affected = await connection.ExecuteWithRetryAsync(
    "DELETE FROM Sessions WHERE ExpiredAt < @Now", new { Now = DateTime.UtcNow });

int count = await connection.ExecuteScalarWithRetryAsync<int>(
    "SELECT COUNT(*) FROM Users WHERE Active = 1");

Transient Fault Detection

SqlTransientFaultDetector.IsTransient classifies SQL errors that are safe to retry: deadlocks (1205), timeouts (‑2, 53, 121), Azure throttling (40197, 40501, 40613, 49918), and transport-level errors. Use it in your own catch blocks:

catch (SqlException ex) when (SqlTransientFaultDetector.IsTransient(ex))
{
    logger.LogWarning(ex, "Transient SQL fault on attempt {Attempt}", attempt);
}

SqlParameter Bridge

Converts anonymous or POCO objects to SqlParameter[] — useful when bridging legacy SqlCommand code or when you need explicit SqlDbType control that Dapper's anonymous parameters don't offer.

// From an anonymous object
IReadOnlyList<SqlParameter> sqlParams = SqlParameterBridge.ToSqlParameters(
    new { UserId = 42, Name = "Alice" });

// With explicit SqlDbType overrides
IReadOnlyList<SqlParameter> sqlParams = SqlParameterBridge.ToSqlParameters(
    new { UserId = 42, Bio = longText },
    new Dictionary<string, SqlDbType>
    {
        ["Bio"] = SqlDbType.NVarChar
    });

// NativeAOT / trimmer-safe generic overload
IReadOnlyList<SqlParameter> sqlParams = SqlParameterBridge.ToSqlParameters<MyParams>(myParams);

🛠 API Reference

Class Purpose Key Members
DapperResilienceExtensions Retry-wrapped Dapper QueryWithRetryAsync<T>, QuerySingleOrDefaultWithRetryAsync<T>, ExecuteWithRetryAsync, ExecuteScalarWithRetryAsync<T>
SqlTransientFaultDetector SQL error classification IsTransient(SqlException)
SqlParameterBridge Object → SqlParameter[] ToSqlParameters(object), ToSqlParameters(object, typeMappings), ToSqlParameters<T>(T)

📦 Dependencies

  • Transformations.Core
  • Dapper
  • Microsoft.Data.SqlClient

License

MIT — Copyright © 2026 opentail.net

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Transformations.Dapper:

Package Downloads
Transformations

Modern .NET transformation helpers for conversion, strings, collections, data, web, diagnostics, batching, and resilience.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.4.2 39 7/7/2026
2.0.4.1 40 7/7/2026
2.0.0 123 4/10/2026