CSharpDB.Sql 1.2.0

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

CSharpDB.Sql

SQL tokenizer, recursive-descent parser, and abstract syntax tree (AST) for the CSharpDB embedded database engine.

NuGet License: MIT

Overview

CSharpDB.Sql provides a complete SQL front-end: a single-pass tokenizer, a recursive-descent parser, and a rich AST hierarchy. It transforms SQL text into strongly-typed statement and expression objects that downstream components (query planner, execution engine) consume. Zero external dependencies.

Features

  • 108 token types covering SQL keywords, literals, identifiers, @parameters, operators, and punctuation
  • Full DDL/DML parsing: CREATE/DROP/ALTER TABLE, CREATE/DROP INDEX, CREATE/DROP VIEW, CREATE/DROP TRIGGER
  • Rich query support: SELECT with JOINs (INNER, LEFT, RIGHT, CROSS), WHERE, GROUP BY, HAVING, ORDER BY, LIMIT/OFFSET, CTEs (WITH)
  • Expression tree: binary/unary operators, LIKE, IN, BETWEEN, IS NULL, aggregate functions (COUNT, SUM, AVG, MIN, MAX with DISTINCT)
  • Fast-path optimizers: TryParseSimpleSelect and TryParseSimplePrimaryKeyLookup detect common patterns and skip full AST construction

Usage

using CSharpDB.Sql;

// Parse a SQL statement
var statements = Parser.Parse("SELECT id, name FROM users WHERE age > 21");

// The result is a list of strongly-typed AST nodes
if (statements[0] is SelectStatement select)
{
    Console.WriteLine($"Table: {select.From}");
    Console.WriteLine($"Columns: {select.Columns.Count}");
    Console.WriteLine($"Has WHERE: {select.Where != null}");
}

// Parse DDL
var ddl = Parser.Parse("""
    CREATE TABLE orders (
        id INTEGER PRIMARY KEY,
        user_id INTEGER,
        total REAL
    )
    """);

// Fast-path detection for simple queries
if (Parser.TryParseSimplePrimaryKeyLookup(sql, out var lookup))
{
    // Skip full parsing for SELECT ... WHERE pk = value
}

AST Hierarchy

Statements: CreateTableStatement, DropTableStatement, InsertStatement, SelectStatement, UpdateStatement, DeleteStatement, AlterTableStatement, CreateIndexStatement, DropIndexStatement, CreateViewStatement, DropViewStatement, CreateTriggerStatement, DropTriggerStatement, WithStatement

Expressions: LiteralExpression, ParameterExpression, ColumnRefExpression, BinaryExpression, UnaryExpression, LikeExpression, InExpression, BetweenExpression, IsNullExpression, FunctionCallExpression

Table References: SimpleTableRef, JoinTableRef (Inner, LeftOuter, RightOuter, Cross)

Installation

dotnet add package CSharpDB.Sql

Dependencies

  • CSharpDB.Core - shared type system and schema definitions
Package Description
CSharpDB.Execution Query planner and operator tree that consumes this AST
CSharpDB.Engine Embedded database engine

License

MIT - see LICENSE for details.

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

Showing the top 2 NuGet packages that depend on CSharpDB.Sql:

Package Downloads
CSharpDB.Engine

Lightweight embedded SQL database engine for .NET. Single-file storage, WAL durability, concurrent readers, and a typed Collection<T> NoSQL API.

CSharpDB.Execution

Query planner, operator tree, and expression evaluator for the CSharpDB embedded database.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 0 3/5/2026
1.1.0 40 3/4/2026
1.0.0 94 3/1/2026