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
I'm not sure about the proper terms here, but basically expression parameters are not equivalent even if they have the same name.
That means that
var param1 = Expression.Parameter(typeof(T), "item");
var param2 = Expression.Parameter(typeof(T), "item");
param1 != param2
param1 and param2 won't be the same thing if used in an expression.
The best way to deal with this is create one parameter up front for your expression, and then pass it to all helper functions that need the parameter.
EDIT: Also, if you're trying to dynamically compose where clauses in LINQ, you could give PredicateBuilder a try.