I\'m trying to create dynamic queries against Entity framework (or other Linq provider).
Let me explain my problem with some sample code.
If I hardcode an ex
You'll need to create a lambda at compile time to close over the id
variable, to which you can then grab the body of an use in the composition of your more complex lambda:
var id = 12345;
ParameterExpression param = Expression.Parameter(typeof(ItemSearch), "s");
Expression prop = Expression.Property(param, "Id");
Expression> idLambda = () => id;
Expression searchExpr = Expression.Equal(prop, idLambda.Body);
Expression> myLambda =
Expression.Lambda>(searchExpr, param);