JLOrdaz.DapperDataMSSQL 1.3.0

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

JLOrdaz.DapperDataMSSQL

Lightweight helper to execute SQL Server stored procedures using Dapper and Microsoft.Data.SqlClient with a simple DI registration.

Install

dotnet add package JLOrdaz.DapperDataMSSQL

Configuration

Add your connection string in appsettings.json (or environment/config provider of your choice):

{
  "ConnectionStrings": {
    "DB": "Server=.;Database=MyDb;Trusted_Connection=True;TrustServerCertificate=True;"
  }
}

Register the library in your DI container and inject ISQLDataAccess where needed.

Program.cs (ASP.NET Core):

var builder = WebApplication.CreateBuilder(args);

// Option 1: Register using connection string name from configuration
builder.Services.AddDapperDataMSSQL(useConnectionStringName: true, connectionStringOrName: "DB");

// Option 2: Register using direct connection string
// builder.Services.AddDapperDataMSSQL(
//     useConnectionStringName: false, 
//     connectionStringOrName: "Server=.;Database=MyDb;Trusted_Connection=True;TrustServerCertificate=True;"
// );

var app = builder.Build();
app.Run();

Parameters:

  • useConnectionStringName: If true, looks up the connection string in configuration. If false, uses the value directly as connection string.
  • connectionStringOrName: The configuration key name (if useConnectionStringName is true) or the actual connection string (if false).

Example repository/service:

using JLOrdaz.DapperDataMSSQL;

public sealed class UserRepository
{
    private readonly ISQLDataAccess _db;

    public UserRepository(ISQLDataAccess db)
    {
        _db = db;
    }

    public Task<IEnumerable<User>> GetUsersAsync() =>
        _db.LoadData<User, object>("dbo.Users_GetAll", new { });

    public Task<User?> GetUserAsync(int id) =>
        _db.LoadFirst<User, object>("dbo.Users_GetById", new { Id = id });

    public Task SaveUserAsync(User user) =>
        _db.SaveData("dbo.Users_Upsert", new { user.Id, user.Name });
}

// Example: stored procedure that returns two result sets (e.g., Users and Roles)
public Task ExampleLoadMultipleAsync(ISQLDataAccess db) =>
    // Assumes stored procedure 'dbo.UsersAndRoles_Get' returns users in first result set and roles in second
    // The new method returns a tuple with both enumerables
    db.LoadMultiple<User, Role, object>("dbo.UsersAndRoles_Get", new { });

// Example: execute stored procedure that returns a scalar value (e.g., newly inserted identity)
public Task<int?> CreateUserAndGetIdAsync(ISQLDataAccess db, User user) =>
    // Assumes stored procedure 'dbo.Users_Insert' inserts and returns the new Id as scalar
    db.ExecuteScalarAsync<int, object>("dbo.Users_Insert", new { user.Name });

Notes:

  • The connection string is configured once during service registration via AddDapperDataMSSQL.
  • storeProcedure is the stored procedure name (schema-qualified recommended).

Dependencies

  • Microsoft.Data.SqlClient
  • Dapper

License

MIT

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

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.3.0 112 1/21/2026
1.1.1 277 4/27/2025