SoftwareMadeSimple.StoredProcedures
1.0.0
There is a newer version of this package available.
See the version list below for details.
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" />
<PackageReference Include="SoftwareMadeSimple.StoredProcedures" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=SoftwareMadeSimple.StoredProcedures&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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:
DapperMicrosoft.Data.SqlClient
Test dependencies:
TUnitTestcontainers.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: optionalDbTypefor 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
nullwhen no rows are returned. - Throws when more than one row is returned.
- Returns
ExecuteWithReturnValueAsynccaptures the SQL Server stored procedureRETURNcode.- 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 | Versions 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.
-
net10.0
- Dapper (>= 2.1.79)
- Microsoft.Data.SqlClient (>= 7.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.