Skip to content

An example of how SQL text can be parsed into lambda expressions using a custom SQL parser

License

Notifications You must be signed in to change notification settings

tswanepoel/sqlgadgetry

Repository files navigation

SQL Gadgetry

The SQL Gadgetry project aims to demonstrate how a string of SQL text can be parsed into a lambda expression tree that, once compiled, can be run using a query provider.

This project was started after realizing how elegant the SQL syntax is for querying any IQueryable, especially in cases when queries need to be built at run-time.

In this example, the SQL query "SELECT Name FROM Customers" is parsed into a lambda expression tree, that is compiled and executed on an instance of List.

Parser

const string sql = "SELECT Name FROM Customers";
LambdaExpression queryExp = new SqlParser().Parse<Context>(sql);

The SQL syntax supported by this initial commit is extremely limited, but hopefully some smart guys could get involved and add the useful stuff too. For now, only a mere select list from one table source will work.

About

An example of how SQL text can be parsed into lambda expressions using a custom SQL parser

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages