ProcWizard 2.0.0

Additional Details

Bug fix: A bug that prevented the correct insertion of the value into the parameter was resolved.

Improvements made: The data mapping was optimized, improving the efficiency and performance of value assignment.

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

ProcWizard

A lightweight, high-performance ORM helper for .NET 8.0 that supports executing raw SQL queries and stored procedures, including advanced features like dynamic parameter binding and table-valued parameters for SQL Server or Oracle collections.

Target Framework: <TargetFramework>net8.0</TargetFramework>


📦 Installation

Install via NuGet:

Install-Package ProcWizard2.0

Or using the .NET CLI:

dotnet add package ProcWizard2.0

🚀 Features

  • Execute SQL queries and stored procedures asynchronously.
  • Supports parameter binding via anonymous objects or DynamicParamBuilder.
  • Optimized for performance using cached expressions.
  • Full support for structured/table-valued parameters.
  • Cross-database support: SQL Server, MySQL, PostgreSQL, Oracle.

⚙️ Basic Usage

Import the namespace

using ProcWizard

Establish a connection

using var connection = new SqlConnection("your-connection-string");

1. Execute a non-query command

await connection.ExecuteAsync(
    "UPDATE Users SET Name = @Name WHERE Id = @Id",
    new { Name = "Alice", Id = 1 }
);

2. Retrieve a single record

var user = await connection.SelectSingleAsync<User>(
    "SELECT Id, Name, Email FROM Users WHERE Id = @Id",
    new { Id = 1 }
);
Console.WriteLine(user.Name);

3. Retrieve a list of records

var users = await connection.SelectListAsync<User>(
    "SELECT * FROM Users WHERE IsActive = @IsActive",
    new { IsActive = true }
);

4. Execute multiple queries with results

var commands = new[]
{
    new MultiCommand { Query = "DELETE FROM Logs", ReturnRows = false },
    new MultiCommand { Query = "SELECT * FROM Orders", ReturnRows = true }
};

var orders = await connection.MultiQueryListAsync<Order>(commands);

5. Execute multiple queries returning a single value

var commands = new[]
{
    new MultiCommand { Query = "INSERT INTO Logs(...) VALUES (...)", ReturnRows = false },
    new MultiCommand { Query = "SELECT COUNT(*) FROM Logs", ReturnRows = true }
};

int logCount = await connection.MultiQuerySingleAsync<int>(commands);

🧠 Advanced Parameter Binding

Use DynamicParamBuilder for fine-grained control over parameters:

var paramBuilder = new DynamicParamBuilder();
paramBuilder.Add("Id", 42);
paramBuilder.Add("Name", "Bob", dbType: SqlServerType.NVarChar, size: 50);

// Structured parameter (e.g. for SQL Server table types)
var data = new[] {
    new { Col1 = 1, Col2 = "A" },
    new { Col1 = 2, Col2 = "B" }
};
paramBuilder.Add("Items", data, dbType: SqlServerType.Structured);

var result = await connection.SelectListAsync<User>(
    "MyStoredProcedure",
    paramBuilder,
    commandType: CommandType.StoredProcedure
);

// Using an anonymous object with both inline parameters and a DynamicParamBuilder
var category = _db.SelectListAsync<Category>(
    "spCategory", 
    new { paramBuilder, p_id = 0, p_user = user.id, dynamicParaman }
);

// Or separating the builder and additional parameters explicitly
var category = _db.SelectListAsync<Category>(
    "spCategory", 
    paramBuilder, 
    new { p_id = 0, p_user = user.id, dynamicParaman }, 
    commandType: CommandType.StoredProcedure
);

📖 Stored Procedures

Stored procedures are fully supported via the CommandType.StoredProcedure flag:

var products = await connection.SelectListAsync<Product>(
    "GetActiveProducts",
    new { IsActive = true },
    commandType: CommandType.StoredProcedure
);

💡 Supported Providers

ProcWizard2.0 dynamically supports the following ADO.NET providers:

  • System.Data.SqlClient (SQL Server)
  • MySql.Data.MySqlClient (MySQL)
  • Npgsql (PostgreSQL)
  • Oracle.ManagedDataAccess.Client (Oracle)

📄 License

This project is licensed under the MIT License.


Happy coding with ProcWizard!

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.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

This project optimizes object mapping and code execution, significantly accelerating the mapping process between SQL database results and C# objects. By reducing overhead and improving performance, it enables faster data handling and more efficient application development.