EricksonLopez.SqlBuilder Overview
EricksonLopez.SqlBuilder (2.0.0 on NuGet, L3) builds immutable, parameterized SQL query ASTs (SelectQuery<T>, InsertQuery<T>, UpdateQuery<T>, DeleteQuery<T>, RawQuery) compiled cleanly across six database dialects without string-concatenation injection risks.
- Immutable AST branching: Every
.Where(...),.OrderByDescending(...), or.Limit(...)call returns a new query instance so base filters can be shared safely across repositories. - Strict identifier & parameter hygiene (
v2.0.0):SqlNamingHelper.ValidateIdentifierrejects malformed identifiers,ParameterManager.AddNamedprevents parameter collisions, and negativeLimit/Offsetvalues fail eagerly. - Pre-compiled Native AOT execution path: Dialect compilers (
PostgreSqlCompiler,SqlServerCompiler, etc.) evaluate expression trees under[RequiresDynamicCode]/[RequiresUnreferencedCode], whileAotConnectionExtensions.AotQueryAsync(connection, SqlResult, mapper)executes pre-compiledSqlResultorRawQuerycommands with[SqlEntity]source-generatedGetReaderParser()for zero-warning Native AOT execution. - Package scope clarity: All
16packages are published (2.0.0,6,827downloads). There is no EF Core integration package insql-builder; the3runtimeIncompatiblepackages areDapper,Oracle, andTesting.
Rendering diagram…
flowchart LR App["Sql.From<T>() / Sql.Raw($...)"] --> AST["Immutable Query AST"] AST --> Comp["ISqlCompiler (PostgreSqlCompiler / SqlServerCompiler / ...)"] Comp --> Res["SqlResult (Sql + ParameterManager)"] Res --> Exec["AotConnectionExtensions (SqlResult + GetReaderParser) / Dapper"]
View accessible text summary and structure
Sql.From builds an immutable SelectQuery AST, ISqlCompiler compiles it into a parameterized SqlResult, and AotConnectionExtensions or Dapper executes it against the target database.
flowchart LR
App["Sql.From<T>() / Sql.Raw($...)"] --> AST["Immutable Query AST"]
AST --> Comp["ISqlCompiler (PostgreSqlCompiler / SqlServerCompiler / ...)"]
Comp --> Res["SqlResult (Sql + ParameterManager)"]
Res --> Exec["AotConnectionExtensions (SqlResult + GetReaderParser) / Dapper"]Package Roster & Native AOT Status (16 / 16 Published)
Section titled “Package Roster & Native AOT Status (16 / 16 Published)”All 16 packages are published at 2.0.0 on NuGet (net8.0;net9.0;net10.0, netstandard2.0 for Roslyn tools; localVersion: 3.0.0 on disk). Overall AOT status is Partial (11 Full, 3 Incompatible, 2 NotApplicable):
| Package | NuGet (2.0.0) |
AOT Status | Role |
|---|---|---|---|
EricksonLopez.SqlBuilder |
Published (1,126 dl) |
Full |
Core AST builders (Sql.From<T>, Insert, Update, Delete, Raw) |
EricksonLopez.SqlBuilder.Abstractions |
Published (1,312 dl) |
Full |
ISqlQuery, ISqlCompiler, SqlResult, [SqlEntity], [Indexed] |
EricksonLopez.SqlBuilder.Aot |
Published (173 dl) |
Full |
AotConnectionExtensions.AotQueryAsync over ADO.NET |
EricksonLopez.SqlBuilder.Dapper.Aot |
Published (162 dl) |
Full |
AotDapperExtensions.AotQueryAsync(connection, SqlResult, mapper) |
EricksonLopez.SqlBuilder.PostgreSql / Sqlite / MySql / SqlServer / MariaDb |
Published (385 / 862 / 332 / 294 / 276 dl) |
Full |
Dialect compilers and provider-specific SQL extensions |
EricksonLopez.SqlBuilder.Pagination |
Published (219 dl) |
Full |
Paginate<T>, ApplyCursor<T, TKey>, ToPagedList<T> |
EricksonLopez.SqlBuilder.OpenTelemetry |
Published (280 dl) |
Full |
SqlBuilderInstrumentation.StartQueryActivity |
EricksonLopez.SqlBuilder.Dapper |
Published (259 dl) |
Incompatible |
IsAotCompatible=false, EnableTrimAnalyzer=false (Dapper runtime emit) |
EricksonLopez.SqlBuilder.Oracle |
Published (309 dl) |
Incompatible |
IsAotCompatible=false (Oracle.ManagedDataAccess.Core) |
EricksonLopez.SqlBuilder.Testing |
Published (281 dl) |
Incompatible |
IsAotCompatible=false, EnableTrimAnalyzer=false |
EricksonLopez.SqlBuilder.Analyzers |
Published (277 dl) |
NotApplicable |
netstandard2.0 Roslyn analyzers (ESQL001–ESQL026, ELSB004/006, SQL0003–0009) |
EricksonLopez.SqlBuilder.SourceGenerators |
Published (280 dl) |
NotApplicable |
netstandard2.0 [SqlEntity] static metadata & GetReaderParser() generator |
Measured directly from BenchmarkDotNet.Artifacts (3 measured rows, 0 na_error rows) in SelectBenchmarks on .NET 10.0.11 X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI (no NativeAOT reports):
SqlBuilder_SimpleSelect: 544 ns / 1,966 BSqlBuilder_ComplexSelect: 1,305.3 ns / 3,738 BSqlBuilder_GroupBy: 1,567.2 ns / 2,478 B