LQL: How Lambda Query Language Simplifies .NET Development

· DataProvider Team

LQL (Lambda Query Language) is a functional pipeline-style DSL that transpiles to SQL. Write database logic once, run it against any supported target.

Why LQL?

Raw SQL strings are error-prone and differ across database vendors. LQL provides:

  • Write once, deploy everywhere — the same query transpiles to PostgreSQL, SQLite, and SQL Server
  • Build-time transpilation — the Lql CLI converts .lql files to dialect-specific SQL during your build
  • Type-safe consumption — the DataProvider CLI turns the generated SQL into extension methods that return Result<T, SqlError>
  • IDE support — the VS Code extension ships with syntax highlighting and a language server (Rust + ANTLR)

Basic example

Users
|> filter(fn(row) => row.Age > 18 and row.Status = 'active')
|> join(Orders, on = Users.Id = Orders.UserId)
|> group_by(Users.Id, Users.Name)
|> select(Users.Name, sum(Orders.Total) as TotalSpent)
|> order_by(TotalSpent desc)
|> limit(10)

Transpile it to SQLite or PostgreSQL:

dotnet tool install Lql --version 0.9.6-beta
dotnet Lql sqlite   --input TopSpenders.lql --output TopSpenders.generated.sql
dotnet Lql postgres --input TopSpenders.lql --output TopSpenders.generated.sql

Runtime transpilation

If you prefer to transpile LQL at runtime instead of build time, reference the dialect library:

dotnet add package Nimblesite.Lql.Postgres --version 0.9.6-beta
using Nimblesite.Lql.Core;
using Nimblesite.Lql.Postgres;
using Nimblesite.Sql.Model;

var statement = new LqlStatement(lqlSource);
Result<string, SqlError> result = statement.ToPostgreSql();

ToSqlite() and ToSqlServer() are also available.

Pipeline operators

The transpiler supports the full set of pipeline operators — filter, select, join / left_join / right_join / full_join, group_by, having, order_by, limit, offset, distinct — plus aggregates (sum, avg, count, min, max) and arithmetic expressions.

Getting started

.NET LQL