How to convert Func <T, bool> to an expression <Func <T, bool >>
3 answers
You can simply write:
Expression<Func<MyClass,bool>> expr = x=>Id == 5;
This will set expras an expression tree for Id == 5.
If you do:
Func<MyClass, bool> func = x=>Id == 5;
Expression<Func<MyClass, bool>> expr = mc => func(mc);
Then it will set expras the expression tree for the call func, not the expression tree for the body func.
+9