Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert Func<T,bool> to Expression<Func<T,bool>>

I have a Func like this :

 Func<MyClass, bool> func = x=>Id == 5;

How I can convert it to :

 Expression<Func<MyClass, bool>>
like image 822
Arian Avatar asked Feb 16 '13 05:02

Arian


1 Answers

Try this:

Func<MyClass, bool> func = x=>Id == 5;
Expression<Func<MyClass, bool>> expr = mc => func(mc);
like image 73
Memoizer Avatar answered Oct 17 '22 17:10

Memoizer