public static Expression <Func <T, bool> > GetPredicate <T>(CriteriaComparator comparator, bool not, Func <T, dynamic> accessor, dynamic value) { var comparatorFunc = comparatorTable[comparator]; var expr = new Func <T, bool>(x => { var res = comparatorFunc(accessor(x), value); return(res); }); // Inverse WHERE predicate if needed (eg. IN / NOT IN) if (not) { expr = PredicateExtensions.Not(expr); } Expression <Func <T, bool> > result = x => expr(x); return(result); }