govaluate icon indicating copy to clipboard operation
govaluate copied to clipboard

Serialize expression to database

Open zeeshan-i-pathan opened this issue 7 years ago • 1 comments

I want to be able to compile and save the expression to the database similar to mvel for performance gain

zeeshan-i-pathan avatar Jul 05 '18 04:07 zeeshan-i-pathan

This might mean a couple different things;

If you want to convert the logic of an expression into a SQL query, that's more or less supported with ToSQLQuery.

The other possibility is saving a "compiled" version of an expression and loading it up later. In that case, I'd recommend serializing the result of Tokens, and when you need to use the expression again, instantiate the expression with FromTokens.

The parsing logic for an expression first turns the string of an expression (e.g., (a + b) / 2) into tokens. Then, it takes the tokens and builds an expression that's in-memory, and made of a bunch of anonymous functions set up in a tree structure - something that can't be serialized. Tokens are as close as you can get to a compiled version of the code.

Knetic avatar Oct 20 '18 19:10 Knetic