ImanSoftware.DataAccess.Dapper 1.0.0

dotnet add package ImanSoftware.DataAccess.Dapper --version 1.0.0
                    
NuGet\Install-Package ImanSoftware.DataAccess.Dapper -Version 1.0.0
                    
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="ImanSoftware.DataAccess.Dapper" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ImanSoftware.DataAccess.Dapper" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ImanSoftware.DataAccess.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 ImanSoftware.DataAccess.Dapper --version 1.0.0
                    
#r "nuget: ImanSoftware.DataAccess.Dapper, 1.0.0"
                    
#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 ImanSoftware.DataAccess.Dapper@1.0.0
                    
#: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=ImanSoftware.DataAccess.Dapper&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ImanSoftware.DataAccess.Dapper&version=1.0.0
                    
Install as a Cake Tool

ImanSoftware.DataAccess.Dapper

Version: 1.0.0 | Last Updated: August 2026

A high-performance Dapper implementation for ImanSoftware.DataAccess, providing fast, lightweight, and efficient SQL data access for .NET applications.

ImanSoftware.DataAccess.Dapper implements the abstractions defined in ImanSoftware.DataAccess using Dapper and Microsoft.Data.SqlClient. It offers efficient query execution, automatic connection management, transaction support, and seamless integration with Dependency Injection.


Installation

Install the package using the .NET CLI:

dotnet add package ImanSoftware.DataAccess.Dapper

Why ImanSoftware.DataAccess.Dapper?

Dapper is one of the fastest micro-ORMs available for .NET, but using it directly often results in repeated connection handling, transaction management, and boilerplate code.

This package combines Dapper's performance with the clean abstractions provided by ImanSoftware.DataAccess.

Benefits include:

  • High-performance data access
  • Minimal overhead
  • Clean Architecture compatible
  • Dependency Injection friendly
  • Consistent Outcome-based error handling
  • Automatic connection management

Features

  • DapperDataAccessor
  • DapperConnectionFactory
  • DapperTransactionScope
  • ✅ Automatic connection management
  • ✅ Stored Procedure support
  • ✅ Parameterized SQL queries
  • ✅ Custom mapping support
  • ✅ Async-first API
  • ✅ Transaction support
  • ✅ Full integration with ImanSoftware.DataAccess

DapperDataAccessor

Implements the ISqlDataAccessor abstraction using Dapper.

Supported operations:

  • QuerySingleAsync<T>()
  • QueryAsync<T>()
  • ExecuteAsync()
  • ExecuteScalarAsync<T>()
  • BeginTransactionAsync()

Example:

var result = await _db.QuerySingleAsync<Product>(
    "GetProductById",
    new
    {
        Id = id
    },
    CommandType.StoredProcedure);

All operations return Outcome objects.


DapperConnectionFactory

Creates SQL Server connections using Microsoft.Data.SqlClient.

Responsibilities include:

  • Connection creation
  • Connection lifetime management
  • Provider abstraction

DapperTransactionScope

Provides transaction management on top of Dapper.

Supported operations:

  • CommitAsync()
  • RollbackAsync()

Example:

await using var transaction =
    await _db.BeginTransactionAsync();

await _db.ExecuteAsync(...);

await transaction.CommitAsync();

Automatic Connection Management

Connections are automatically:

  • Opened when required
  • Reused during transactions
  • Closed when operations complete
  • Properly disposed

This keeps application code clean while preventing connection leaks.


Custom Mapping

The package supports Dapper's custom mapping capabilities, allowing database schemas to be mapped cleanly to domain models.

Example scenarios include:

  • Different column names
  • Complex object mapping
  • Legacy database integration

Dependency Injection

Register the Dapper implementation:

services.AddDapperDataAccess(connectionString);

Alternatively, register it through the generic Data Access configuration.

services.AddDataAccess(connectionString);

Example

using ImanSoftware.DataAccess.Dapper;

public class ProductService
{
    private readonly ISqlDataAccessor _db;

    public ProductService(ISqlDataAccessor db)
    {
        _db = db;
    }

    public async Task<Outcome<int>> CreateProductAsync(Product product)
    {
        var parameters = new
        {
            product.Name,
            product.Price
        };

        return await _db.ExecuteAsync(
            "InsertProduct",
            parameters,
            CommandType.StoredProcedure);
    }
}

Stored Procedure Example

await _db.ExecuteAsync(
    "InsertProduct",
    new
    {
        product.Name,
        product.Price
    },
    CommandType.StoredProcedure);

Ad-hoc SQL Example

await _db.QueryAsync<Product>(
    @"SELECT *
      FROM Products
      WHERE CategoryId = @CategoryId",
    new
    {
        CategoryId = categoryId
    });

Design Goals

  • High performance
  • Thin abstraction over Dapper
  • Async-first API
  • Dependency Injection friendly
  • Automatic connection management
  • Transaction support
  • Lightweight
  • Outcome-based error handling
  • Clean Architecture compatible

Requirements

  • .NET Standard 2.0+
  • .NET 6+
  • .NET 7+
  • .NET 8+
  • .NET 9+
  • .NET 10.0+

Dependencies

  • ImanSoftware.DataAccess
  • ImanSoftware.Outcome
  • Dapper
  • Microsoft.Data.SqlClient

Author

Iman Estiri

📧 contact.imanestiri@gmail.com

📧 dev.imanestiri@gmail.com

GitHub:

https://github.com/ImanEstiri


License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET 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 ImanSoftware.DataAccess.Dapper:

Package Downloads
ImanSoftware.Framework

Umbrella package that bundles all ImanSoftware modules for a unified development experience.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 165 8/3/2026