sqlkata / querybuilder

SQL query builder, written in c#, helps you build complex queries easily, supports SqlServer, MySql, PostgreSql, Oracle, Sqlite and Firebird
https://sqlkata.com
MIT License
3.08k stars 498 forks source link

Any plans to introduce compiler for in-memory data? #649

Open nikhilsarvaiye opened 1 year ago

nikhilsarvaiye commented 1 year ago

Any plans to introduce compiler for in-memory data in lists, collections? which can be useful in case of caching like Redis, or for general code performance.

I would love to know your thoughts, if would like I can contribute, thoughts?

ahmad-moussawi commented 1 year ago

Nice idea!, but I don't think it's a matter of the compiler only. The job of a compiler is to convert C# statements to SQL string statements, so maybe a package with a broader scope would be needed in this case.

nikhilsarvaiye commented 1 year ago

Right, I would say we build Query and then Query to filter in-memory dictionaries. This way we can reuse the query object, I also have few ideas where and how joins can work in memory...

Cricle commented 1 year ago

I think DataTable.Select can use

michaelkruglos commented 1 year ago

Has anyone tried SQLite in-memory feature? I've found this, but I haven't tried it yet. It sure seems as a viable solution for unit tests, where you would use it for in-memory mock DB.

ahmad-moussawi commented 1 year ago

The unit tests already use this, I think you can follow the same approach

https://github.com/sqlkata/querybuilder/blob/master/QueryBuilder.Tests/SQLiteExecutionTest.cs#L263-L267

var cs = $"Data Source=file::memory:;Cache=Shared";
var connection = new SqliteConnection(cs);
var db = new QueryFactory(connection, new SqliteCompiler());