SoftwareMadeSimple.StoredProcedures 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SoftwareMadeSimple.StoredProcedures --version 1.0.0
                    
NuGet\Install-Package SoftwareMadeSimple.StoredProcedures -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="SoftwareMadeSimple.StoredProcedures" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SoftwareMadeSimple.StoredProcedures" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SoftwareMadeSimple.StoredProcedures" />
                    
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 SoftwareMadeSimple.StoredProcedures --version 1.0.0
                    
#r "nuget: SoftwareMadeSimple.StoredProcedures, 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 SoftwareMadeSimple.StoredProcedures@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=SoftwareMadeSimple.StoredProcedures&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=SoftwareMadeSimple.StoredProcedures&version=1.0.0
                    
Install as a Cake Tool

StoredProcedures

A small .NET library for executing SQL Server stored procedures using Dapper under the hood.

It provides a focused API for common stored procedure scenarios:

  • Execute a procedure with no result set.
  • Read a single scalar value.
  • Read a single mapped row.
  • Read a mapped list.
  • Read the stored procedure return value.

Target Framework

  • .NET 10 (net10.0)

Dependencies

Library dependencies:

  • Dapper
  • Microsoft.Data.SqlClient

Test dependencies:

  • TUnit
  • Testcontainers.MsSql

Installation

Install from NuGet:

dotnet add package SoftwareMadeSimple.StoredProcedures --version 1.0.0

Or add a package reference manually:

<ItemGroup>
  <PackageReference Include="SoftwareMadeSimple.StoredProcedures" Version="1.0.0" />
</ItemGroup>

Quick Start

using System.Data;
using SoftwareMadeSimple.StoredProcedures;

var connectionString = "Server=localhost;Database=MyDb;User Id=sa;Password=Your_password123;TrustServerCertificate=true;";
var executor = new Executor(connectionString);

var parameters = new List<StoredProcedureParameter>
{
    new("userId", 42, DbType.Int32)
};

// Execute (no result)
await executor.ExecuteAsync("dbo.DoWork", parameters);

// Scalar result
var count = await executor.ExecuteScalarAsync<int?>("dbo.GetCount", parameters);

// Single row result
var user = await executor.ExecuteSingleAsync<UserDto>("dbo.GetUser", parameters);

// List result
var users = await executor.ExecuteListAsync<UserDto>("dbo.GetUsers", parameters);

// Stored procedure return value
var returnValue = await executor.ExecuteWithReturnValueAsync("dbo.DoWorkWithReturnCode", parameters);

public sealed record UserDto(int Id, string Name);

Public API

StoredProcedureParameter

  • Name: parameter name (without @ in typical usage).
  • Value: parameter value.
  • DbType: optional DbType for explicit SQL type control.

IExecutor

  • ExecuteAsync(...)
  • ExecuteScalarAsync<T>(...)
  • ExecuteSingleAsync<T>(...)
  • ExecuteListAsync<T>(...)
  • ExecuteWithReturnValueAsync(...)

Behavior Notes

  • All calls are asynchronous and support CancellationToken.
  • Commands run as CommandType.StoredProcedure.
  • ExecuteSingleAsync<T> uses Dapper single-row semantics:
    • Returns null when no rows are returned.
    • Throws when more than one row is returned.
  • ExecuteWithReturnValueAsync captures the SQL Server stored procedure RETURN code.
    • Internally, a unique return-value parameter name is used to avoid collisions with user-provided parameters.

Running Tests

From the repository root:

dotnet test

Tests use:

  • SQL Server in a container (mcr.microsoft.com/mssql/server:2022-latest)
  • Automatic database setup per test flow

Prerequisites for integration tests:

  • Docker, or a Docker-compatible API endpoint, must be installed and running.

Repository Layout

src/StoredProcedures/        Library source
tests/StoredProcedures.Tests/ Integration tests

License

See 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

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.1 50 11/19/2026
1.0.0 169 7/10/2026