Ily*_*gan 5 .net c# linq expression-trees
我需要将参数传递给需要的方法Expression<Func<T, bool>>.
怎么做我传递一个总会返回的表达式true?
使用obj => true不起作用,因为框架在运行时抱怨它无法从True常量确定memeber类型.
thi*_*ing 11
如果你有这样的功能
void TakeExpression<T>(Expression<Func<T, bool>> expr)
Run Code Online (Sandbox Code Playgroud)
您应该这样调用它,指定T类型:
TakeExpression<int>(_ => true)
Run Code Online (Sandbox Code Playgroud)
它应该工作.