bjornharrtell / PgKeyValueDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support query by lambda in all Get methods

Revsgaard opened this issue · comments

Support query by lambda with a Expression<Func<T, bool>> whereQuery = null parameter in all get mehods.

@bjornharrtell lambda support would be a nice and performance optimization feature.

Agreed but it's likely non trivial. However existing implementation does exist in Npgsql EF Core support (https://www.npgsql.org/efcore/mapping/json.html#querying-json-columns-traditional-json-and-dom) but I'm not sure it can be used externally.

No, Npgsql EF Core can probably not be used.

The solution is probably to generate the select string based on the Expression<Func<T, bool>> query in the CreateGetCommand method.
https://stackoverflow.com/questions/2399009/how-does-c-sharp-lambda-work

Yes but I mean such logic already exists within the Npgsql EF Core logic, might extractable. And could even suggest to the Npgsql project it should be externalised in its own package.

@Revsgaard I've looked into this a bit and I think there is a bit of impedance between expression and jsonb indexing/operators. Some basic things is not too hard, fx. containment which fx. can be used to check exact equality for a single propery value. But I fail to see that it's possible to generally support something similar to "like" operator on a property value. So the expression translation will be quite limited and I wonder how useful it will be.