Expression.Or, The parameter 'item' is not in scope

前端 未结 5 1140
一整个雨季
一整个雨季 2021-02-09 00:23

I am trying to write a static function to Or two expressions, but recieve the following error:

The parameter \'item\' is not in scope.

Descrip

5条回答
  •  伪装坚强ぢ
    2021-02-09 00:38

    The issue is that the Expression you're creating in the method OrExpressions reuses the body of the two expressions. Those bodies will contain references to their own ParameterExpression that has been defined in FilterExpression.

    A fix would be to rewrite the left and right parts to use the new ParameterExpression. Or to pass the original ParameterExpression along. It's not because the two ParameterExpression have the same name that they represent the same parameter.

提交回复
热议问题