SQLStoredProcedureCommandsFunctions 1.0.9

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

SQLStoredProcedureCommandsFunctions 1.0.9

A lightweight yet powerful SQL Server data-access library that simplifies working with stored procedures, DataTables, SQL parameters, and Azure SQL authentication.
Built for .NET 10 enterprise applications requiring clean, reusable, and high-performance database access.


πŸš€ Features

βœ” Azure SQL Authentication (Managed Identity Ready)

  • Environment-aware token generation
  • Local: VisualStudioCredential
  • Cloud: DefaultAzureCredential
  • Automatic AccessToken injection into SqlConnection
  • Zero code changes required when deploying to Azure

βœ” Full Data Access Layer (DAL)

Rich APIs for executing SQL commands:

  • ExecuteNonQuery
  • ExecuteScalar
  • ExecuteDataset
  • ExecuteReader
  • ExecuteXmlReader

Supports:

  • sync & async programming
  • Connection string, SqlConnection, or SqlTransaction
  • Stored procedures or raw SQL
  • Automatic command preparation

βœ” SQLSPResultMapper Introduction

New high-level strongly-typed stored procedure execution layer built on top of the existing DAL.

SQLSPResultMapper allows executing a stored procedure once and automatically mapping results into:

  • List<T>
  • IEnumerable<T>
  • Multi-table β†’ Dictionary<string, List<T>>
  • Dynamic β†’ Dictionary<string, List<Dictionary<string, object?>>>

Supports:

  • Sync & Async methods
  • Automatic DataSet β†’ POCO mapping
  • Case-insensitive column-property matching
  • Nullable property handling
  • DBNull β†’ null conversion
  • Multi-table stored procedure support
  • Clean service-layer integration
  • Output / InputOutput / ReturnValue helper methods for SQL parameters

Example:

UserDto users = await SQLSPResultMapper.ExecuteToListAsync<UserDto>(
    connectionString,
    commandType,
    "GetUsers",
    sqlParameters);

⚑ Output / InputOutput / ReturnValue Helpers

These helper methods make it easy to define SQL parameters for stored procedures with outputs or return values:

// Output parameter

SqlParameter outputParam = SQLSPResultMapper.Output("OutputParamName", SqlDbType.Int);

// InputOutput parameter

SqlParameter inputOutputParam = SQLSPResultMapper.InputOutput("InputOutputParamName", someValue);

// Return value parameter

SqlParameter returnValueParam = SQLSPResultMapper.ReturnValue();

Designed to eliminate repetitive DataTable conversion code and reduce boilerplate in enterprise applications and microservices.


βœ” Stored Procedure Parameter Caching

  • Automatically discovers stored procedure parameters
  • Caches them using synchronized hashtable
  • Fast repeated execution
  • Eliminates DeriveParameters overhead

βœ” SQL Parameter Utilities

  • Convert C# classes β†’ SqlParameter list
  • [IgnoreDBParameter] attribute to skip properties
  • Automatic SqlDbType inference
  • Create strongly typed parameters easily

βœ” Data Conversion Helpers

  • DataTable β†’ List<T> / IEnumerable<T>
  • List<T> / IEnumerable<T> β†’ DataTable
  • DataSet / DataTable β†’ Dictionary
  • Column reordering & shifting utilities

βœ” Dynamic Mapping Engine

  • Attribute-based mapping ([MapFrom])
  • DB column β†’ custom property name mapping
  • Case-insensitive mapping support
  • Supports nullable types & enums

βœ” Smart SQL Builder

Fluent SQL query builder (SELECT, FROM, WHERE) Conditional filters (WhereIf) IN / NOT IN support LIKE / NOT LIKE search helpers Pagination support (OFFSET / FETCH) JOIN, GROUP BY, HAVING Parameterized queries (SQL Injection safe)

Example: Smart SQL Builder

var builder = new SmartSQLBuilder()
    .Select("Id, Name, SalesOrg")
    .From("Customers")
    .WhereLike("Name", "A")
    .WhereIn("SalesOrg", new[] { "TW31", "TW32" })
    .Pagination(1, 10);

var result = builder.Build();

Console.WriteLine(result.Query);

Example: DataTable β†’ Model Mapping

public class Customer
{
    public int Id { get; set; }

    [MapFrom("Name")]
    public string CustomerName { get; set; }

    public string SalesOrg { get; set; }
}

DataTable dt = GetDataFromDatabase();

Customer customers = DataMapper.Map<Customer>(dt);

foreach (var c in customers)
    Console.WriteLine(c.CustomerName);

Example: Execute Query

SqlParameter sqlParams = result.Parameters
    .Select(p => new SqlParameter(p.Key, p.Value ?? DBNull.Value))
    .ToArray();

using var reader = await DataAccessLayer.ExecuteReaderAsync(
    connectionString,
    CommandType.Text,
    result.Query,
    sqlParams
);

πŸ”„ Data Flow

UI Filters ↓ SmartSQLBuilder ↓ SQL + Parameters ↓ DataAccessLayer ↓ DataTable / Reader ↓ DataMapper ↓ Strongly Typed Models ↓ JSON Response

βœ” Developer Experience

Easy to integrate into existing projects Works with Dapper / ADO.NET Reduces boilerplate code Improves readability and maintainability

🎯 Use Cases

Dynamic filtering APIs Data transformation layers Repository pattern implementations Legacy system modernization Rapid backend development

βœ” Legacy-style SqlHelper (Optional)

  • Transaction support
  • Bulk SP execution
  • Dataset update utilities

πŸ“¦ Installation

Install from NuGet:

dotnet add package SQLStoredProcedureCommandsFunctions --version 1.0.9
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.9 111 4/28/2026
1.0.8 104 4/28/2026
1.0.7 115 3/23/2026
1.0.6 115 3/23/2026
1.0.5 124 2/23/2026
1.0.4 113 2/23/2026
1.0.1 337 12/16/2025
1.0.0.9 309 12/16/2025
1.0.0.8 729 12/3/2025
1.0.0.7 714 12/3/2025
1.0.0.6 2,075 11/20/2025 1.0.0.6 is deprecated because it is no longer maintained and has critical bugs.
1.0.0.4 1,822 7/4/2025 1.0.0.4 is deprecated because it is no longer maintained and has critical bugs.
1.0.0.3 276 10/10/2024
1.0.0.2 601 10/13/2023
1.0.0.1 582 10/13/2023

Release Notes - v1.0.9

     βœ¨ Key Features

     🔹 1. Azure SQL Authentication

     Added AzureCredential helper with environment-aware token resolution.

     Supports:
     - Local development via VisualStudioCredential
     - Cloud environments via DefaultAzureCredential
     - Automatic access token generation for SQL connections.

     (Files: AzureCredential.cs)


     🔹 2. High-Performance Stored Procedure Execution

     Execute NonQuery, Scalar, Reader, Dataset, XmlReader operations.

     Full support for sync and async methods.

     Overloads for:
     - Raw SQL commands
     - Stored procedure name
     - Parameter arrays
     - Strongly-typed object parameters


     🔹 3. Built-In Transaction Support

     Easy transaction lifecycle management:
     - InitializeTransaction()
     - Commit()
     - Rollback()

     Safe handling of shared connections.


     🔹 4. Automatic SQL Parameter Discovery & Caching

     SQLHelperParameterCache creates and caches stored procedure parameter sets.

     - Avoids repeated trips to SQL Server using DeriveParameters.
     - Provides deep clones to ensure thread-safety.
     - Improves performance in high-load systems.


     🔹 5. Object-to-SQL Parameter Mapping

     SQLParamHelper allows:

     - Auto-generation of SqlParameter list from an object.
     - Support for numeric, string, GUID, datetime, boolean, and other primitives.
     - Attribute [IgnoreDbParameter] to omit properties from mapping.
     - Strongly typed parameter creation helpers.


     🔹 6. SQLSPResultMapper – Strongly-Typed Result Mapping

     Introduced SQLSPResultMapper to simplify stored procedure result handling.

     Enables execution + automatic mapping into:

     - List<T>
     - IEnumerable<T>
     - Dictionary<string, List<T>> (multi-table strong typing)
     - Dictionary<string, List<Dictionary<string, object?>>> (dynamic mapping)

     Supports:
     - Sync & Async execution
     - Case-insensitive column/property matching
     - Nullable property handling
     - DBNull β†’ null conversion
     - Multi-table stored procedures
     - Clean integration with service-layer architecture

     Eliminates repetitive DataTable-to-List conversion logic.

     Designed for microservices and enterprise APIs.


     🔹 7. DataSet & DataTable Conversion Utilities

     Included in DataAccessConverter, offering:

     Convert:
     - DataTable β†’ List<T>
     - DataTable β†’ IEnumerable<T>
     - DataSet β†’ Dictionary<string, List<object>>
     - List<T> β†’ DataTable
     - Multiple lists β†’ DataSet

     Advanced helpers:
     - Select distinct values
     - Shift column ordering
     - Move/rename table columns


     🔹 8. Extension Methods for DataTable Manipulations

     Included in DataTableExtensions:

     - Move one or more columns to specific indices.
     - Get column names by index.
     - Reorder columns without breaking row data.


     🔹 9. Streamlined Data Access Layer

     The DataAccessLayer class provides a clean API for:

     - Sync/async CRUD operations
     - Command preparation
     - Reader handling

     Strong validation for:
     - Connection state
     - Null parameters
     - Argument correctness

     🔹 10. Dynamic Mapping Engine - (NEW - 2026-04-28)

     Introduced [MapFrom] attribute for flexible column mapping

     Supports DB column β†’ custom property mapping

     Case-insensitive mapping support

     Handles nullable types and enums

     🔹 11. Smart SQL Builder - (NEW - 2026-04-28)

     Fluent SQL builder for SELECT, FROM, WHERE

     Conditional filtering with WhereIf

     IN / NOT IN support

     LIKE / NOT LIKE helpers

     Pagination support (OFFSET / FETCH)

     Support for JOINs, GROUP BY, HAVING

     Fully parameterized queries (SQL Injection safe)


     🔧 Internal Enhancements

     - Safe cloning of SQL parameters before execution.
     - Consistent use of CommandTimeout for long-running procedures.
     - Support for both internal and external connection ownership modes.
     - Uses Microsoft.Data.SqlClient for modern SQL Server connectivity.
     - Centralized execution pipeline reused by SQLSPResultMapper.


     🐛 Known Limitations

     - Does not support Dapper-style automatic mapping (future enhancement possible).
     - SQL bulk copy not included in this version.
     - Parameter type inference follows simplified rules and may need extension for complex types.
     - Reflection-based mapping (expression-tree optimization planned for future release).


     📦 Target Frameworks

     -.NET 8, .NET 9, .NET 10


     📘 Documentation

     For full samples, including:
     - CRUD examples
     - Async patterns
     - Stored procedure patterns
     - Strongly-typed mapping examples
     - Multi-table stored procedure handling