public static IStringFilterOperator CreateFilterOperatorRule(StringFilterOperator filterOp, string value)
        {
            switch (filterOp)
            {
            case StringFilterOperator.Contains:
                return(new ContainsOperator {
                    Value = value
                });

            case StringFilterOperator.Equals:
                return(new EqualsOperator {
                    Value = value
                });

            case StringFilterOperator.NotContains:
                return(new NotContainsOperator {
                    Value = value
                });

            case StringFilterOperator.StartsWith:
                return(new StartsWithOperator {
                    Value = value
                });

            case StringFilterOperator.EndwsWith:
                return(new EndsWithOperator {
                    Value = value
                });

            case StringFilterOperator.NotEquals:
                return(new NotEqualsOperator {
                    Value = value
                });

            case StringFilterOperator.NotIsEmpty:
                return(new NotIsEmptyOperator {
                    Value = value
                });

            case StringFilterOperator.IsEmpty:
                return(new IsEmptyOperator());

            default:
                throw new Exception("Invalid Rule");
            }
        }
        public static Expression <Func <T, bool> > BuildFilterExpression <T>(string propertyName, object propertyValue, StringFilterOperator op = StringFilterOperator.Equals)
        {
            var parameterExp = Expression.Parameter(typeof(T), typeof(T).ToString());

            MemberExpression propertyExp;

            if (propertyName.Contains('.'))
            {
                var propSplit = propertyName.Split('.');
                propertyExp = Expression.PropertyOrField(Expression.PropertyOrField(parameterExp, propSplit[0]), propSplit[1]);
            }
            else
            {
                propertyExp = Expression.PropertyOrField(parameterExp, propertyName);
            }

            switch (op)
            {
            case StringFilterOperator.StartsWith:
            case StringFilterOperator.EndsWith:
            case StringFilterOperator.Contains:
            {
                MethodInfo method    = typeof(string).GetMethod(op.ToString(), new[] { typeof(string) });
                var        someValue = Expression.Constant(propertyValue, typeof(string));
                var        methodExp = Expression.Call(propertyExp, method, someValue);
                return(Expression.Lambda <Func <T, bool> >(methodExp, parameterExp));
            }

            case StringFilterOperator.Equals:
            {
                var bodyExp = Expression.Equal(propertyExp, Expression.Constant(propertyValue));
                return(Expression.Lambda <Func <T, bool> >(bodyExp, parameterExp));
            }
            }

            return(null);
        }