HsSqlAgent.SqlCore 3.1.0

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

HsSqlAgent.SqlCore

Driver-free SQL parsing, static analysis, and fail-closed compilation for .NET.

HsSqlAgent.SqlCore is the compiler library used by hs-sql-agent. It supports six SQL dialects: PostgreSQL, MySQL, SQL Server, Oracle, SQLite, and Firebird. Syntax and capabilities are deliberately provider- and version-specific; support for a dialect does not mean every statement is executable.

The compiler uses a closed F# AST, typed validation and capability checks, and provider-native rendering behind a CLR-friendly C# facade. It does not connect to a database or execute SQL.

Capabilities

Support depends on statement shape, provider, version, compilation policy and proof inputs.

Family Compilation Static analysis
DQL CompileQuery: supported SELECT shapes and proven dialect transformations Query binding, dependencies and diagnostics through script analysis
DML CompileDml: supported INSERT / UPDATE / DELETE and bounded conflict / MERGE forms Modeled mutation effects and dependencies, with explicit uncertainty
DDL CompileDdl, limited PostgreSQL CompileDdlBatch, immutable plans and static PreviewDdl Modeled schema changes, virtual catalog evolution and dependencies

The six dialects do not have identical support. Cross-provider compilation requires proven transformations. Parsing a statement does not imply compilation support.

ParseScript / AnalyzeScript also cover bounded DCL, transaction, session, utility and procedural models. Analysis simulates catalog/effects in statement order and reports uncertainty; it does not determine actual affected rows or replace a database optimizer.

Compilation requires no human approval. Consumers receive SQL, parameters and plans, and choose their own execution workflow.

Install

dotnet add package HsSqlAgent.SqlCore

Compile a query

using HsSqlAgent.SqlCore;
using HsSqlAgent.SqlCore.Core.Pipeline;
using HsSqlAgent.SqlCore.Enums;

var command = SqlCoreFacade.CompileQuery(
    "SELECT 1",
    SqlAgentToolType.Postgres,
    SqlAgentToolType.Postgres,
    new SqlPlanValidationContext("my-query-policy"),
    new SqlExecutionPlanPolicy(100));

Console.WriteLine(command.Sql);

CompiledSqlCommand contains native SQL, bound parameters, and compiler evidence. The caller remains responsible for database access, connection identity, permissions, and runtime limits.

Other compiler APIs

API Purpose
CompileQuery / TryCompileQuery Validate and render a query under an explicit policy
CompileDml / TryCompileDml Validate and render a bounded mutation under DML policy and applicable proof requirements
CompileDdl / TryCompileDdl Compile an explicitly supported single DDL operation into an immutable schema plan
CompileDdlBatch / TryCompileDdlBatch Compile the limited, proven PostgreSQL DDL batch topologies
PreviewDdl / TryPreviewDdl Inspect a static before/expected-after schema change
ParseScript / AnalyzeScript Inspect multi-statement SQL, catalog effects, dependencies, and uncertainty

Use the SqlCoreFacade APIs from HsSqlAgent.SqlCore. More advanced overloads accept typed source/target capability profiles, compilation policies, proof inputs, and cancellation tokens.

Analyze a script without executing it

using HsSqlAgent.SqlCore;
using HsSqlAgent.SqlCore.Catalog;
using HsSqlAgent.SqlCore.Enums;
using HsSqlAgent.SqlCore.Script;

var analysis = SqlCoreFacade.AnalyzeScript(
    "CREATE TABLE demo (id INT); SELECT id FROM demo;",
    new SqlScriptAnalysisOptions(
        SqlAgentToolType.Postgres,
        SqlCatalogState.KnownEmpty()));

Console.WriteLine(analysis.EffectCoverage);

KnownEmpty() is an explicit caller assertion about the starting virtual catalog. Without it, analysis starts from an unknown/open-world catalog. Neither state proves the real database schema.

Compile a DDL plan, not a database change

using HsSqlAgent.SqlCore;
using HsSqlAgent.SqlCore.Ddl;
using HsSqlAgent.SqlCore.Enums;

var options = new DdlCompilationOptions(
    SqlAgentToolType.Postgres,
    SqlAgentToolType.Postgres);

var preview = SqlCoreFacade.PreviewDdl(
    "CREATE TABLE public.demo (id INTEGER NOT NULL)",
    options);

Console.WriteLine(preview.Plan.Command.Sql);
Console.WriteLine(preview.AuthorizesExecution); // False

DDL preview computes a static before/expected-after schema diff from the supplied virtual catalog. It does not inspect a live database. Supported operations and batches depend on provider and statement shape.

Package boundary

SqlCore contains dialect-aware parsing, source spans, binding, typed semantics, source/target capability checks, compilation, immutable plans and static analysis. Database drivers, connections, transactions and execution belong to the consumer.

Unsupported syntax, ambiguous identities and unproven transformations are rejected. The package does not claim complete SQL grammar or cross-dialect equivalence.

Documentation

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 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 (2)

Showing the top 2 NuGet packages that depend on HsSqlAgent.SqlCore:

Package Downloads
HsSqlAgent.Server

Embeddable MCP SQL Agent components for ASP.NET Core with composable runtime, MCP, administration, authentication, UI, and telemetry capabilities.

HsSqlAgent.Provider.Abstractions

Provider runtime contracts, base implementation and driver-neutral error mapping for HsSqlAgent.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.1.0 163 11/14/2026
3.0.0 415 10/25/2026
2.0.6 179 10/18/2026
2.0.5 222 9/8/2026
2.0.4 209 9/7/2026
2.0.3 212 9/5/2026
2.0.2 185 9/4/2026
2.0.1 195 9/3/2026
2.0.0 190 9/2/2026