I understand that this is a very old answer, but I think the selected answer is misleading because the finder was looking for an expression and the selected answer contains lambda.
, IQueryable IEnumerable<T>, IQueryable<T>. Linq.
, .
public static class NegationExpressionHelper
{
public static IQueryable<T> WhereNot<T>(this IQueryable<T> queryable, Expression<Func<T,bool>> predicate)
{
return queryable.Where(predicate.Invert());
}
public static Expression<Func<T, bool>> Invert<T>(this Expression<Func<T, bool>> original)
{
return Expression.Lambda<Func<T, bool>>(Expression.Not(original.Body), original.Parameters.Single());
}
}