Combining two expressions (Expression<Func<T, bool>>)
I have a method taking in a single
void MethodOne(Expression<Func<bool>> expression)
I've got multiple instances of
Expression<Func<bool>>. How do I dynamically combine these expressions into a single
Expression.OrElse (i.e. building up an expression tree)?
For example if I have two expressions such as
() => objectA.PropertyOneIsSet
() => objectB.PropertyTwoIsSet
I want the end result to be:
() => objectA.PropertyOneIsSet || objectB.PropertyTwoIsSet
so I can pass this to my method above.
You could use expressions.Any(x => x.CallMethod) in order to achieve this goal.