Is there a framework out there that can read a string of C# that is pulled from a database and run it as code?
Kind of like a calculator works...
I just want an idea of how hard it is to do something like this. Or to develop something that can make it happen.
Let's say there is a nvarchar
column that I return from a database that has something like this in it:
(a + b - c)
In my code I know what a, b, and c are equivalent to, but how do I replace the values and get it to run as code? Essentially it is what a compiler does.
If you want to disregard the SQL part, how would I execute a string with a formula in it as code in my application:
int a = 1;
int b = 2;
int c = 1;
string formula = "(a + b - c)"