I'm writing the expression extensions method which must inverse the bool
-typed lambda expression.
Here is what I am doing:
public static Expression<Func<T, bool>> Inverse<T>(this Expression<Func<T, bool>> e)
{
return Expression.Lambda<Func<T, bool>>(Expression.Not(e));
}
But this raises an exception, that unary operator is NOT not defined for the type Func<int,bool>
.
I also tried this:
public static Expression<Func<T, bool>> Inverse<T>(this Expression<Func<T, bool>> e)
{
return Expression.Lambda<Func<T, bool>>(Expression.Not(e.Body));
}
But getting this: Incorrent number of parameters supplied for lambda declaration
.
null
I think? Like when you doMethod.Invoke
, just curious if that is the case. – Lentha