Hysen Labs
Library / SDK
DomanyDusan/lambda-sql-builder avatar
DomanyDusan

lambda-sql-builder

A small independent library that will let you use standard C# and Linq to produce SQL queries

50 stars21 forksC#NOASSERTION
01
DEEP OPEN-SOURCE ANALYSIS

Building SQL queries in C# without string literals

A small .NET library that turns C# and Linq into strongly typed SQL, supporting SQL Server 2008 and 2012, born from an author tired of SQL strings.

02
DEEP OPEN-SOURCE ANALYSIS

The one feature it keeps

Lambda SQL Builder exists because its author wanted exactly one thing: generate SQL from C# and Linq without string literals lying around in the application. No change tracking, no sessions, none of the machinery of a full ORM. The README reports that after switching to micro ORMs the author replaced 99 percent of the queries needed in recent projects, which is the practical payoff of a library that deliberately does one thing.

03
DEEP OPEN-SOURCE ANALYSIS

What it supports

The support section is modest. Apart from standard SQL queries, the currently supported databases are SQL Server 2008 and SQL Server 2012, and the minimum .NET version is 4.0. It is not trying to cover the whole SQL world. The README says additional SQL adapters are in development to widen database specific support, so the compatibility story is explicitly a work in progress.

04
DEEP OPEN-SOURCE ANALYSIS

Where the idea came from

The inspiration is spelled out: Linq2SQL, Entity Framework, and QueryOver in NHibernate. The author was a fan of these big ORMs but got headaches from them, then moved to the micro ORM trend. What got lost in that move was the single feature of writing queries with strong typing. The library can sit alongside SQLCommand, Dapper, or even NHibernate, which is the point of keeping it independent.

05
DEEP OPEN-SOURCE ANALYSIS

How a query gets built

Usage follows a consistent pattern: create a SqlLam object, call methods on it, then read the results. The QueryString property returns the SQL string and the QueryParameters property holds a dictionary of the parameters. Internally a Lambda Resolver translates the expressions into SQL strings, and a SQL Builder collects them into clauses like selection, join, and order by. Variables in an expression end up in the parameters dictionary, and the clauses combine into a single statement when you ask for the query string. The methods can be chained if you prefer that style.

07
DEEP OPEN-SOURCE ANALYSIS

Official sources

08
Community notes

Community notes