I have a situation where I need to logically-combine two expressions:
Expression<Func<T1, bool>> expr1; Expression<Func<T2, bool>> expr2;
In some cases, T1 and T2 are the same type, and in those cases, I want to logically combine the bodies of the two expressions (using && or ||), rather than combine calls to each of them. but I can’t combine them because expr1 can’t be cast to the type of expr2.
So, in the case where typeof(T1) == typeof(T2)
, what is the best way to logically-combine the bodies of the two expressions such that they both operate on the argument type T1?
Unable to cast variable of type Expression<Func<T1, bool>> to Expression<Func<T2, bool>>