How to convert an Expression> to a Predicate

前端 未结 3 1050
醉话见心
醉话见心 2021-01-30 10:32

I have a method that accepts an Expression> as a parameter. I would like to use it as a predicate in the List.Find() method, but I can\'t

3条回答
  •  迷失自我
    2021-01-30 10:58

    Another options which hasn't been mentioned:

    Func func = expression.Compile();
    Predicate predicate = new Predicate(func);
    

    This generates the same IL as

    Func func = expression.Compile();
    Predicate predicate = func.Invoke;
    

提交回复
热议问题