public static Expression GetAssignExpressionBoolean(FilterOperator filterOperator,
                                                            Expression left, Expression right, Type propertyType)
        {
            switch (filterOperator)
            {
            case FilterOperator.IsEqualTo:
                return(Expression.Equal(left, right));

            case FilterOperator.IsNotEqualTo:
                return(Expression.NotEqual(left, right));

            case FilterOperator.IsContainedIn:
                return(ExpressionExtensions.IsContainedInExpression(left, right, propertyType));

            case FilterOperator.IsNotContainedIn:
                var isContainedIn = ExpressionExtensions.IsContainedInExpression(left, right, propertyType);
                return(Expression.Not(isContainedIn));

            //Comparisons can't be applied to boolean
            case FilterOperator.Contains:
            case FilterOperator.DoesNotContain:
            case FilterOperator.IsGreaterThan:
            case FilterOperator.IsLessThan:
            case FilterOperator.IsGreaterThanOrEqualTo:
            case FilterOperator.IsLessThanOrEqualTo:
            case FilterOperator.StartsWith:
            case FilterOperator.EndsWith:
                return(null);

            default:
                return(null);
            }
        }
        public static Expression GetAssignExpressionEnum(FilterOperator filterOperator,
                                                         Expression left, ConstantExpression right, Type propertyType)
        {
            Type            enumType;
            UnaryExpression convertExpression;
            UnaryExpression convertValue;

            switch (filterOperator)
            {
            case FilterOperator.IsEqualTo:
                return(Expression.Equal(left, right));

            case FilterOperator.IsNotEqualTo:
                return(Expression.NotEqual(left, right));

            case FilterOperator.IsGreaterThan:
                enumType          = Enum.GetUnderlyingType(propertyType);
                convertExpression = Expression.Convert(left, enumType);
                convertValue      = Expression.Convert(right, enumType);
                return(Expression.GreaterThan(convertExpression, convertValue));

            case FilterOperator.IsLessThan:
                enumType          = Enum.GetUnderlyingType(propertyType);
                convertExpression = Expression.Convert(left, enumType);
                convertValue      = Expression.Convert(right, enumType);
                return(Expression.LessThan(convertExpression, convertValue));

            case FilterOperator.IsGreaterThanOrEqualTo:
                enumType          = Enum.GetUnderlyingType(propertyType);
                convertExpression = Expression.Convert(left, enumType);
                convertValue      = Expression.Convert(right, enumType);
                return(Expression.GreaterThanOrEqual(convertExpression, convertValue));

            case FilterOperator.IsLessThanOrEqualTo:
                enumType          = Enum.GetUnderlyingType(propertyType);
                convertExpression = Expression.Convert(left, enumType);
                convertValue      = Expression.Convert(right, enumType);
                return(Expression.LessThanOrEqual(convertExpression, convertValue));

            case FilterOperator.IsContainedIn:
                return(ExpressionExtensions.IsContainedInExpression(left, right, propertyType));

            case FilterOperator.IsNotContainedIn:
                var isContainedIn = ExpressionExtensions.IsContainedInExpression(left, right, propertyType);
                return(Expression.Not(isContainedIn));

            //Comparisons can't be applied to Enums
            case FilterOperator.Contains:
            case FilterOperator.DoesNotContain:
            case FilterOperator.StartsWith:
            case FilterOperator.EndsWith:
                return(null);

            default:
                return(null);
            }
        }