ISC.Dapper.SqlClient.DependencyInjection 1.0.0

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

ISC.Dapper.SqlClient.DependencyInjection

ISC.Dapper.SqlClient.DependencyInjection is a lightweight package that provides:

  • IDapperContext abstraction for Dapper operations.
  • DapperContext implementation for SQL Server.
  • A simple foundation for building your own app-level context factory pattern.

Target Framework

  • .NET 8.0

Installation

dotnet add package ISC.Dapper.SqlClient.DependencyInjection

Quick Start

1) Register your factory in the application

using ISC.Dapper.SqlClient.DependencyInjection;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddScoped<DapperContextFactory>();

2) Implement DapperContextFactory

This example follows your read/write factory approach:

using ISC.Dapper.SqlClient.DependencyInjection;

public class DapperContextFactory
{
    private readonly IConfiguration _configuration;
    private readonly string _connectionStringRead;
    private readonly string _connectionStringWrite;

    public DapperContextFactory(IConfiguration configuration)
    {
        _configuration = configuration;
        _connectionStringRead = _configuration.GetConnectionString("ChannelHubsService")
            ?? "";
        _connectionStringWrite = _configuration.GetConnectionString("ChannelHubsService")
            ?? "";
    }

    public IDapperContext ReInventReadContext() => new DapperContext(_connectionStringRead);
    public IDapperContext ReInventWriteContext() => new DapperContext(_connectionStringWrite);
    public string GetConnectionStringWrite() => _connectionStringWrite;
}

3) Use the factory in services/repositories

using ISC.Dapper.SqlClient.DependencyInjection;

public sealed class UserRepository
{
    private readonly DapperContextFactory _contextFactory;

    public UserRepository(DapperContextFactory contextFactory)
    {
        _contextFactory = contextFactory;
    }

    public async Task<IEnumerable<UserDto>> GetUsersAsync()
    {
        var dapperContext = _contextFactory.ReInventReadContext();
        const string sql = "SELECT Id, UserName FROM dbo.Users";
        return await dapperContext.QueryAsync<UserDto>(sql);
    }
}

API Overview

IDapperContext

  • QueryAsync<T>(...)
  • QuerySingleAsync<T>(...)
  • ExecuteAsync(...)
  • ExecuteScalarAsync<T>(...)
  • BeginTransactionAsync()
  • CommitTransaction(...)
  • RollbackTransaction(...)
  • OpenConnection()
  • CloseConnection()

Best Practices

  • Prefer separate read/write connection strings when your infrastructure supports it.
  • Throw early if a required connection string is missing.
  • Keep one consistent context creation strategy across your application.

License

Add your project license here (for example: MIT).

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 was computed.  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 was computed.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 82 3/30/2026