EricksonLopez.SqlBuilder
dotnet-sql-builder · Querying & Data
On this page (20 sections)
1. Identity, Tier & Maturity Profile#
2. Value Proposition & Problem Solved#
Immutable, Native AOT-first SQL query builder and high-performance execution ecosystem for .NET 8, 9 & 10. Features type-safe AST compilation, zero-reflection source generators, Roslyn analyzers, and dialect compilers for PostgreSQL, SQL Server, MySQL, MariaDB, SQLite, and Oracle.
Heavy ORMs add change-tracking overhead and unpredictable LINQ translation, while raw concatenated SQL strings lack refactoring safety and risk SQL injection.
3. Quick Install#
Primary package: EricksonLopez.SqlBuilder
dotnet add package EricksonLopez.SqlBuilder --version 2.0.0<PackageReference Include="EricksonLopez.SqlBuilder" Version="2.0.0" /><PackageVersion Include="EricksonLopez.SqlBuilder" Version="2.0.0" />4. Verified Ecosystem Metrics#
Snapshot retrieved UTC: 2026-12-01
5. When to Use & When Not to Use#
When to use
- You want immutable SQL AST query builders (SelectQuery<T>, InsertQuery<T>, UpdateQuery<T>, DeleteQuery<T>) compiled across 6 database dialects.
When NOT to use
- You want domain-layer expression predicates (`Expression<Func<T, bool>>`)—use EricksonLopez.Specification.
6. Core Capabilities & Design Invariants#
Immutable AST & Roslyn Generators
Record-based query composition with CTEs, window functions, LATERAL joins, and compile-time [SqlEntity] metadata.
6 Dialect Compilers & Analyzers
Pay-for-play packages for PostgreSQL, SQL Server, MySQL, MariaDB, SQLite, and Oracle plus SQL safety analyzers.
7. Included NuGet Packages & Adapters#
| Package ID | Status | NuGet / Local | TFMs | AOT Status | Downloads | Description |
|---|---|---|---|---|---|---|
| EricksonLopez.SqlBuilderPrimary | Published | v2.0.0 / v3.0.0 | net8.0, net9.0, net10.0 | AOT: Full | 1,126 | Immutable NativeAOT-friendly SQL Builder core — AST, query builders, expression visitors, and dialect compilation contracts. |
| EricksonLopez.SqlBuilder.Abstractions | Published | v2.0.0 / v3.0.0 | net8.0, net9.0, net10.0 | AOT: Full | 1,312 | Contracts, interfaces, and AST node definitions for EricksonLopez.SqlBuilder. |
| EricksonLopez.SqlBuilder.Sqlite | Published | v2.0.0 / v3.0.0 | net8.0, net9.0, net10.0 | AOT: Full | 862 | Package Description |
| EricksonLopez.SqlBuilder.PostgreSql | Published | v2.0.0 / v3.0.0 | net8.0, net9.0, net10.0 | AOT: Full | 385 | AOT-compatible AST compiler for the PostgreSQL dialect with LATERAL joins, materialized CTEs, and window function FILTER support. |
| EricksonLopez.SqlBuilder.MySql | Published | v2.0.0 / v3.0.0 | net8.0, net9.0, net10.0 | AOT: Full | 332 | Package Description |
| EricksonLopez.SqlBuilder.Oracle | Published | v2.0.0 / v3.0.0 | net8.0, net9.0, net10.0 | AOT: Incompatible | 309 | Package Description |
| EricksonLopez.SqlBuilder.SqlServer | Published | v2.0.0 / v3.0.0 | net8.0, net9.0, net10.0 | AOT: Full | 294 | Package Description |
| EricksonLopez.SqlBuilder.Testing | Published | v2.0.0 / v3.0.0 | net8.0, net9.0, net10.0 | AOT: Incompatible | 281 | Package Description |
| EricksonLopez.SqlBuilder.OpenTelemetry | Published | v2.0.0 / v3.0.0 | net8.0, net9.0, net10.0 | AOT: Full | 280 | Package Description |
| EricksonLopez.SqlBuilder.MariaDb | Published | v2.0.0 / v3.0.0 | net8.0, net9.0, net10.0 | AOT: Full | 276 | Package Description |
| EricksonLopez.SqlBuilder.Dapper | Published | v2.0.0 / v3.0.0 | net8.0, net9.0, net10.0 | AOT: Incompatible | 259 | Seamless integration with Dapper and OpenTelemetry for EricksonLopez.SqlBuilder. |
| EricksonLopez.SqlBuilder.Pagination | Published | v2.0.0 / v3.0.0 | net8.0, net9.0, net10.0 | AOT: Full | 219 | Pagination integration for EricksonLopez.SqlBuilder. Provides offset and keyset cursor pagination extension methods for SelectQuery AST. |
| EricksonLopez.SqlBuilder.Aot | Published | v2.0.0 / v3.0.0 | net8.0, net9.0, net10.0 | AOT: Full | 173 | Reflection-free, NativeAOT-compatible query execution layer for EricksonLopez.SqlBuilder. Executes compiled SQL directly over IDbConnection using source-generated entity mappers, with no runtime code generation and no dependency on Dapper. |
| EricksonLopez.SqlBuilder.Dapper.Aot | Published | v2.0.0 / v3.0.0 | net8.0, net9.0, net10.0 | AOT: Full | 162 | Dapper.AOT and NativeAOT reflection-free execution extensions for EricksonLopez.SqlBuilder. Provides strongly-typed, allocation-free SQL query execution over DbConnection without runtime code generation. |
| EricksonLopez.SqlBuilder.SourceGeneratorsAnalyzer / Generator | Published | v2.0.0 / v3.0.0 | netstandard2.0 | AOT: N/A (Analyzer/Legacy) | 280 | Roslyn analyzers and AOT source generators for EricksonLopez.SqlBuilder. |
| EricksonLopez.SqlBuilder.AnalyzersAnalyzer / Generator | Published | v2.0.0 / v3.0.0 | netstandard2.0 | AOT: N/A (Analyzer/Legacy) | 277 | Roslyn Analyzers for EricksonLopez.SqlBuilder. |
8. Quick Start Code Example#
Grounded in verified public APIs from EricksonLopez.SqlBuilder. Compile with `<ImplicitUsings>disable</ImplicitUsings>` and explicit imports.
using System;
using EricksonLopez.SqlBuilder.Annotations;
[SqlEntity("users")]
public partial class UserRecord
{
[DatabaseGenerated]
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public bool IsActive { get; set; }
}9. Architecture & Dependency Flow#
Rendering diagram…
flowchart LR lib_sql_builder["EricksonLopez.SqlBuilder (L3)"] lib_result["EricksonLopez.Result (L0)"] lib_sql_builder --> lib_result lib_pagination["EricksonLopez.Pagination (L2)"] lib_sql_builder -.-> lib_pagination lib_dapper_extensions["EricksonLopez.DapperExtensions (L3)"] lib_dapper_extensions -.-> lib_sql_builder
View accessible text summary and structure
2 upstream library dependencies and 1 downstream dependent libraries verified in dependencies.json.
| Direction | Library | Tier | Relationship Kinds |
|---|---|---|---|
| Upstream | EricksonLopez.Result | L0 | Compile-Time, NuGet Package |
| Upstream | EricksonLopez.Pagination | L2 | Adapter, NuGet Package |
| Downstream | EricksonLopez.DapperExtensions | L3 | Adapter, NuGet Package |
flowchart LR
lib_sql_builder["EricksonLopez.SqlBuilder (L3)"]
lib_result["EricksonLopez.Result (L0)"]
lib_sql_builder --> lib_result
lib_pagination["EricksonLopez.Pagination (L2)"]
lib_sql_builder -.-> lib_pagination
lib_dapper_extensions["EricksonLopez.DapperExtensions (L3)"]
lib_dapper_extensions -.-> lib_sql_builder10. Target Frameworks & Native AOT / Trimming Matrix#
MSBuild `.csproj` inspection across 16 packages: 11 Full, 0 Partial, 3 Incompatible, 2 NotApplicable (analyzers/generators).
| Package ID | IsAotCompatible | EnableTrimAnalyzer | Verified AOT Status | Target Frameworks |
|---|---|---|---|---|
| EricksonLopez.SqlBuilder | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.SqlBuilder.Abstractions | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.SqlBuilder.Sqlite | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.SqlBuilder.PostgreSql | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.SqlBuilder.MySql | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.SqlBuilder.Oracle | false | true | Incompatible | net8.0, net9.0, net10.0 |
| EricksonLopez.SqlBuilder.SqlServer | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.SqlBuilder.Testing | false | false | Incompatible | net8.0, net9.0, net10.0 |
| EricksonLopez.SqlBuilder.OpenTelemetry | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.SqlBuilder.MariaDb | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.SqlBuilder.Dapper | false | false | Incompatible | net8.0, net9.0, net10.0 |
| EricksonLopez.SqlBuilder.Pagination | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.SqlBuilder.Aot | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.SqlBuilder.Dapper.Aot | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.SqlBuilder.SourceGenerators | null | null | NotApplicable | netstandard2.0 |
| EricksonLopez.SqlBuilder.Analyzers | null | null | NotApplicable | netstandard2.0 |
11. Upstream Dependencies & Downstream Dependents#
Upstream Dependencies (2)
Downstream Dependents (1)
12. Optional Adapters & Third-Party Integrations#
Internal Adapter Edges & Integration Packages
- EricksonLopez.DapperExtensions→ EricksonLopez.SqlBuilder.Abstractions
- EricksonLopez.SqlBuilder.Dapper→ EricksonLopez.Pagination (EricksonLopez.Pagination)
- EricksonLopez.SqlBuilder.Dapper→ EricksonLopez.Pagination.Abstractions (EricksonLopez.Pagination)
- EricksonLopez.SqlBuilder.Pagination→ EricksonLopez.Pagination (EricksonLopez.Pagination)
- EricksonLopez.SqlBuilder.Pagination→ EricksonLopez.Pagination.Abstractions (EricksonLopez.Pagination)
Verified External NuGet Dependencies (22)
13. Configuration & DI Registration Summary#
Verified DI & Configuration Entry Points
DeleteQuery<T>.AddNodeAppends the specified node to the query AST.
InsertQuery<T>.AddNodeAppends the specified node to the query AST.
SelectQuery<T>.AddNodeAppends the specified node to the query AST.
UpdateQuery<T>.AddNodeAppends the specified node to the query AST.
IParameterManager.AddNamedAdds a named parameter value and returns its formatted parameter name in the dialect's syntax.
InsertBuilder<T>.AddRuleAdds a custom column selection rule to the insert operation.
UpdateBuilder<T>.AddRuleAdds a custom column selection rule to the update operation.
OracleParameterManager.AddNamedAdds a named parameter value and returns its formatted parameter name in the dialect's syntax.
Key Public Types & Contracts
EricksonLopez.SqlBuilder.AotSqlRendererBase (class)Provides a base implementation for an AOT-compatible SQL renderer that generates SQL statements using pooled `Text.StringBuilder` buffers (pool-rented, not allocation-free for SQL assembly) and zero-allocation data materialization for the `IDataReader → T` hot path.
EricksonLopez.SqlBuilder.CursorPaginationExtensions (class)Provides extension methods for implementing keyset (cursor-based) pagination.
EricksonLopez.SqlBuilder.DeleteQuery`1 (record)Represents a DELETE query syntax tree builder for the specified entity type.
EricksonLopez.SqlBuilder.DiffUpdateExtensions (class)Provides extension methods for generating UPDATE statements based on entity state differences.
EricksonLopez.SqlBuilder.DynamicSortingExtensions (class)Provides extension methods for applying dynamic sorting to queries using string-based column names.
EricksonLopez.SqlBuilder.InsertQuery`1 (record)Represents an INSERT query syntax tree builder for the specified entity type.
EricksonLopez.SqlBuilder.Param (class)Provides factory methods for creating explicitly typed SQL parameters.
EricksonLopez.SqlBuilder.QueryContract (record)Represents the verifiable shape of a compiled query.
EricksonLopez.SqlBuilder.QueryContractExtensions (class)Provides extension methods for generating query contracts.
EricksonLopez.SqlBuilder.RawQuery (record)Represents a raw SQL query that is always fully parameterized. Unlike Dapper's raw string approach, `RawQuery` never accepts string concatenation and enforces NativeAOT-safe parameter passing.
EricksonLopez.SqlBuilder.SelectQuery`1 (record)Represents a SELECT query syntax tree builder for the specified entity type.
EricksonLopez.SqlBuilder.Sql (class)Provides entry points and static factory methods for constructing type-safe SQL queries.
14. Verified Performance Benchmarks#
All verified measurements below come strictly from `BenchmarkDotNet.Artifacts` running on .NET RyuJIT (0 NativeAOT benchmark runs exist in this snapshot).
| Suite | Method | Runtime | Mean (ns) | Allocated (B) | Status |
|---|---|---|---|---|---|
| SelectBenchmarks | SqlBuilder_SimpleSelect | .NET 10.0.11 X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI | 544 | 1,966 | measured |
| SelectBenchmarks | SqlBuilder_ComplexSelect | .NET 10.0.11 X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI | 1,305.3 | 3,738 | measured |
| SelectBenchmarks | SqlBuilder_GroupBy | .NET 10.0.11 X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI | 1,567.2 | 2,478 | measured |
15. Release History & NuGet vs Repo Status#
Version lag detected: NuGet.org latest published version is v2.0.0, while local repository HEAD is at v3.0.0.
| Version | Source | Published Date | Summary |
|---|---|---|---|
| v2.0.0 ↗ | nuget | 2026-09-24 | Published EricksonLopez.SqlBuilder 2.0.0 to NuGet.org. |
| v2.0.0 ↗ | github | 2026-09-24 | [2.0.0](https://github.com/ericksonlopezf/dotnet-sql-builder/compare/v1.0.0...v2.0.0) (2026-09-24) ⚠ BREAKING CHANGES * implement security invariants, AST validation, and dialect enhancements ✨ Features * implement security invariants, AST validation, and dialect enhancements ([d6bc61a](https://github.com/ericksonlopezf/dotnet-sql-builder/commit/d6bc61a2dc9d6ade2e0828f9ebfab813fd217325)) |
| v1.0.0 ↗ | github | 2026-08-29 | Ecosystem Packages in this release | Package | Version | |---------|---------| | `EricksonLopez.SqlBuilder.Abstractions` | `1.0.0` | | `EricksonLopez.SqlBuilder` | `1.0.0` | | `EricksonLopez.SqlBuilder.Aot` | `1.0.0` | | `EricksonLopez.SqlBuilder.Analyzers` | `1.0.0` | | `EricksonLopez.SqlBuilder.Dapper` | `1.0.0` | | `EricksonLopez.SqlBuilder.Dapper.Aot` | `1.0.0` | | `EricksonLopez.SqlBuilder... |
| v1.0.0 ↗ | nuget | 2026-08-29 | Published EricksonLopez.SqlBuilder 1.0.0 to NuGet.org. |
16. Complementary & Related Libraries#
Libraries in the same tier, architectural layer, or directly paired via dependency edges.
17. Documentation, API Reference & Portal Links#
Conceptual Documentation (Starlight) →
Extracted XML API Reference →
34 namespaces · 244 types · 1452 members
Ecosystem Dependency Map →
Learning Center & Handbook →
Per-library conceptual Starlight pages expand in M4; API Reference pages expand in M3.2.
18. Source Repository, License & Contributing#
Released under the MIT License. All assemblies follow EricksonLopez.* build invariants: explicit imports, strong-name signing (`EricksonLopez.snk`), and ASCII author metadata (`Erickson Lopez`).
19. Troubleshooting, Pitfalls & Migration Guidance#
- Core, Dapper.Aot, and 5 dialect compilers are Full AOT; SqlBuilder.Dapper, SqlBuilder.Oracle, and SqlBuilder.Testing declare IsAotCompatible=false.
- Version lag detected: NuGet.org latest published version is v2.0.0, while local repository HEAD is at v3.0.0.
20. Quality & Verification Evidence#
- Strong-Name Signing (`EricksonLopez.snk`)
- EricksonLopez.snk
- `ImplicitUsings=disable`
- disable
- XML Documentation Extraction
- Verified (34 namespaces, 244 types, 1452 members)
- MSBuild AOT / Trim Attributes
- 11 Full / 0 Partial / 3 Incompatible / 2 N/A
- BenchmarkDotNet Artifacts
- 3 total (3 measured, 0 na_error)
Explicit Verification Boundaries & Limitations
- All verified measurements below come strictly from `BenchmarkDotNet.Artifacts` running on .NET RyuJIT (0 NativeAOT benchmark runs exist in this snapshot).