vendredi 27 mars 2020

Evaluation Expression

Our Company is having a Framework which requests Queries as Expression(Func(T, bool)) where T is the given Type ob the Buiniess Object.

I need to write an Provider for this and what to evaluate the Content of the Expression

If i have Queries like:

Expression<Func<Person, bool>> expr;
expr = (p) => p.Name == "Smith";

this is no Problem, then I can Use the Body Property of the Expression giving the following Result

Body = {(p.Name == "Smith")}

If i use Variables like this:

Expression<Func<Person, bool>> expr;
string nameToFind = "Smith";
expr = (p) => p.Name == name;

I get the following Result:

Body = {(p.Name == value(TestConsole.Program+<>c__DisplayClass0_0).nameToFind)}

What I want is the have in this case the Variables Value in the parsed Expression like in the first example without variables.

Is ths possible? I would be very greatful for an example or hint





Aucun commentaire:

Enregistrer un commentaire