Suppose I have something like
Expression<Func<SomeType, DateTime>> left = x => x.SomeDateProperty;
Expression<Func<SomeType, DateTime>> right = x => dateTimeConstant;
var binaryExpression = Expression.GreaterThan(left, right);
Expression<Func<SomeType, bool>> predicate =
x => x.SomeDateProperty> dateTimeConstant;
1) How can I replace the right hand of the assignment of the last line with something that uses the binaryExpression
instead? var predicate = x => binaryExpression;
doesn't work.
2) The right
is always a constant, not necessarily DateTime.Now. Could it be of some simpler Expression
type? For instance, it doesn't depend on SomeType, it is just a constant.
3) If I have the GreaterThan
as a string
, is there a way to get from this string to the method with the same name in Expression
? In general, if the name of the comparison method is given as a string
, how can I go from the string to actually calling the method with the same name on the Expression
class?
It has to work with LINQ to Entities, if it matters.