Namh.Data.DynamicSql 1.0.0

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

dynamic-sql

Build powerful database screens without creating a CLR class for every table.

dynamic-sql turns runtime metadata, C# expressions, or YAML definitions into safe, provider-specific SQL. The same query engine can power a data grid, report builder, admin screen, or API endpoint even when the fields and relationships are selected at runtime.

A query defined by data

var rows = db.QueryYml("""
Entity: User
Projection:
  - Name
  - Manager.Name | Manager-Name
Filter: "[Name] like 'Dav%' && [Age] >= 18"
Sorts: Manager.Name DESC
Page: 1
PageSize: 50
""").ToList();

No generated entity class. No hand-written join. No string-built SQL.

The same metadata can be queried from C#:

var rows = db.Query("User")
    .Where(user => user["Age"] >= 18)
    .Select("Name", "Manager.Name")
    .ToList();

Why it is different

  • Runtime entities, fields, relationships, and aggregates.
  • One compiler for C# expressions and YAML queries.
  • Relationship paths such as Manager.Name and Members.Name.
  • Dynamic projections and aliases without CLR models.
  • SQL Server, SQLite, and PostgreSQL dialect support.
  • Parameterized filters and executable SQL diagnostics.
  • A dialect-independent SQL expression intermediate representation.
var sql = db.QueryYml(yml).ToSql();
Console.WriteLine(sql.CommandText);

For SQL Server, the diagnostic output includes typed DECLARE statements, so the complete text can be copied directly into a query window.

Start here

  • Read the user manual for installation, metadata, queries, YAML, providers, async APIs, and troubleshooting.
  • Read the technical guide for the compiler pipeline and important classes.
  • See the query model reference for the canonical backend JSON format for projections and query contexts.

Targets: .NET 8, .NET 9, and .NET 10.

Run the demo

Install the .NET 10 SDK, Node.js with npm, and Windows Terminal, then run this from the repository root in PowerShell:

.\start.ps1

The script installs frontend dependencies on first run, then opens the API and frontend in separate, titled Windows Terminal tabs, in that order. The API's Swagger UI is at http://localhost:21210/swagger; the frontend is at http://localhost:5173.

The demo backend is split into four projects: Demo.WebApi hosts the API and registers dependencies, Demo.Services contains application logic, Demo.Contracts defines service and repository abstractions, and Demo.Repositories implements file, in-memory, and database access. Set StorageProvider in src/Demo.WebApi/appsettings.json to Files (default) or Memory to select the metadata, function-definition, and report store. Reports are exposed through the /report API. Built-in metadata and SQL functions are shared, read-only definitions; built-in reports are loaded from the existing query-request storage folder src/Demo.WebApi/FileStorage/QueryRequests/*.yml and can be edited and run but not saved or deleted. Custom metadata, functions, and reports are stored under FileStorage/UserData/{SectionId}/ and are isolated by section. Database connections remain selected separately through DbServerType. The IQueryRequestRepository stores QueryDefinition YAML files in FileStorage/QueryRequests for built-ins and FileStorage/UserData/{SectionId}/QueryRequests for custom requests. These files use the flat QueryDefinition YAML shape (for example, Entity and Fields are top-level properties).

License

MIT License. See MANUAL.md for the full license text.

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 is compatible.  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 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 115 10/27/2026
1.0.0 101 10/27/2026