ActDim.Practix.RepoDb 1.4.0

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

ActDim.Practix.RepoDb

ActDim.Practix.RepoDb provides RepoDb extensions, lambda expression SQL translators, and best practices for ActDim.Practix.

Features

  • Expression-Based Interpolated SQL Generator (conn.DefineSql): Define SQL queries using clean C# string interpolation ((c, o) => $"...") where properties and tables resolve automatically to RepoDB mapped names and table aliases without inner lambdas.
  • Bound Execution Context (BoundSql): Captures the active database connection and compiled SQL. Provides ExecuteQueryAsync<TResult>, ExecuteNonQueryAsync, ExecuteScalarAsync<TResult>, and ExecuteReaderAsync where developers specify only the target materialization type and query parameters.
  • Standalone SQL Templates (SqlTemplate): Define reusable SQL templates without a live connection instance and render against specific database settings or bind to active connections.
  • Fluent Helper Extensions: High-productivity helpers built on top of RepoDb (ExecuteInTransactionAsync, NormalizeSqlPattern).

Installation

dotnet add package ActDim.Practix.RepoDb

Quick Start

1. Single Table Query & Direct Column Resolution

using ActDim.Practix.RepoDb.Extensions;

// Define and execute a query in one chain:
var users = await conn.DefineSql<User>(u => $"""
    SELECT {u.Id} AS Id, {u.FullName} AS Name, {u.Email}
    FROM {u}
    WHERE {u.IsActive} = @active
    """)
    .ExecuteQueryAsync<UserDto>(new { active = true });

// Directly resolve mapped column name in expressions:
var cmd = conn.DefineSql<User>(t => $"SELECT 1 AS {t.Id}");
// Result SQL: SELECT 1 AS [Id]

2. Multi-Table JOIN with Automatic Table Aliases

// Lambda parameter names (c, o) become the SQL table aliases:
var orders = await conn.DefineSql<Customer, Order>((c, o) => $"""
    SELECT 
        {c.Id} AS CustomerId,
        {c.FullName} AS CustomerName,
        {o.OrderId} AS OrderId,
        {o.TotalAmount} AS Total
    FROM {c}
    JOIN {o} ON {c.Id} = {o.CustomerId}
    WHERE {o.Status} = @status
    """)
    .ExecuteQueryAsync<OrderSummaryDto>(new { status = "Completed" });

3. Inspection, Debugging & Logging via ToString()

var bound = conn.DefineSql<Customer, Order>((c, o) =>
    $"SELECT {c.Id}, {o.TotalAmount} FROM {c} JOIN {o} ON {c.Id} = {o.CustomerId}");

// Inspect the compiled SQL directly in debugger or logs:
logger.LogInformation("SQL to execute: {Sql}", bound.ToString());

// Execute scalar or non-query:
var count = await bound.ExecuteScalarAsync<int>();

4. Standalone SQL Templates & Dialect-Specific Rendering

using ActDim.Practix.RepoDb;
using ActDim.Practix.RepoDb.Sql;

// Define a reusable template without a connection instance:
var template = SqlTemplate.Define<Customer, Order>((c, o) =>
    $"SELECT {c.Id}, {o.TotalAmount} FROM {c} JOIN {o} ON {c.Id} = {o.CustomerId}");

// Render without database drivers:
string pgSql = template.Render(SqlDialect.PostgreSql); // "c"."Id", "Customer" AS "c"
string mySql = template.Render(SqlDialect.MySql);      // `c`.`Id`, `Customer` AS `c`
string sqliteSql = template.Render(SqlDialect.Sqlite); // [c].[Id], [Customer] AS [c]

// Define directly targeting a dialect:
var pgQuery = SqlBuilder.For(SqlDialect.PostgreSql).Define<Customer, Order>((c, o) =>
    $"SELECT {c.Id} FROM {c}");

// Bind to an active connection when ready to execute:
var results = await conn.Bind(template).ExecuteQueryAsync<OrderDto>();

AI-Assisted Development

Developed with Along - a provider-agnostic context and memory system for AI coding agents.


License

This project is licensed under the MIT 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 (1)

Showing the top 1 NuGet packages that depend on ActDim.Practix.RepoDb:

Package Downloads
ActDim.BytePath.SqliteRegistry

SQLite metadata registry implementation for ActDim.BytePath with distributed locking, TTL expiration, and WAL mode support.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.0 97 9/29/2026
1.3.0 103 9/24/2026
1.2.0 107 9/22/2026
1.1.0 105 9/21/2026