/// <summary>
 /// インスタンスを生成します。
 /// </summary>
 /// <param name="@operator">演算子</param>
 /// <param name="type">左辺のインスタンスの型</param>
 /// <param name="propertyName">プロパティ名</param>
 /// <param name="value">値</param>
 internal PredicateElement(PredicateOperator @operator, Type type = null, string propertyName = null, object value = null)
 {
     this.Operator = @operator;
     this.Type = type;
     this.PropertyName = propertyName;
     this.Value = value;
 }
 /// <summary>
 /// Extends the specified source Predicate with another Predicate and the specified PredicateOperator.
 /// </summary>
 /// <typeparam name="T">The type</typeparam>
 /// <param name="first">The source Predicate.</param>
 /// <param name="second">The second Predicate.</param>
 /// <param name="operator">The Operator (can be "And" or "Or").</param>
 /// <returns>Expression{Func{T, bool}}</returns>
 public static Expression <Func <T, bool> > Extend <T>(
     [NotNull] this Expression <Func <T, bool> > first,
     [NotNull]      Expression <Func <T, bool> > second,
     PredicateOperator @operator = PredicateOperator.Or)
 {
     return(@operator == PredicateOperator.Or ? first.Or(second) : first.And(second));
 }
 /// <summary>
 /// インスタンスを生成します。
 /// </summary>
 /// <param name="@operator">演算子</param>
 /// <param name="type">左辺のインスタンスの型</param>
 /// <param name="propertyName">プロパティ名</param>
 /// <param name="value">値</param>
 internal PredicateElement(PredicateOperator @operator, Type type = null, string propertyName = null, object value = null)
 {
     this.Operator     = @operator;
     this.Type         = type;
     this.PropertyName = propertyName;
     this.Value        = value;
 }
        /// <summary>
        /// Sets the condition.
        /// </summary>
        /// <typeparam name="T">Type of predicate values.</typeparam>
        /// <param name="operator">The predicate operator.</param>
        /// <param name="values">The values.</param>
        /// <returns>The parent query builder for call chaining.</returns>
        private TParent SetCondition <T>(PredicateOperator @operator, T[] values)
        {
            predicate.@operator = @operator;
            if (typeof(T) == typeof(string))
            {
                predicate.values = Array.ConvertAll(values, delegate(T value)
                {
                    // backslash, singlequote and doublequotes should be escaped. See
                    // https://developers.google.com/adwords/api/docs/guides/awql#notes_1
                    return("'" + value.ToString()
                           // Replace backslashes first, so double-escaping won't happen.
                           .Replace("\\", "\\\\").Replace("\"", "\\\"").Replace("'", "\\'") + "'");
                });
            }
            else if (typeof(T) == typeof(bool))
            {
                // When using a Boolean condition in a predicate, it should be sent as TRUE or FALSE.
                predicate.values = Array.ConvertAll(values, value => value.ToString().ToUpper());
            }
            else
            {
                predicate.values = Array.ConvertAll(values, value => value.ToString());
            }

            return(queryBuilder);
        }
 public void OutputPredicateOperator(PredicateOperator valueSet)
 {
     OutputStatusMessage(string.Format("Values in {0}", valueSet.GetType()));
     foreach (var value in Enum.GetValues(typeof(PredicateOperator)))
     {
         OutputStatusMessage(value.ToString());
     }
 }
 /// <summary>
 /// Adds a filter to select only items where the value of
 /// <paramref name="field"/> satisfies a particular condition.
 /// </summary>
 /// <param name="field">The field to filter on.</param>
 /// <param name="operator">The predicate operator.</param>
 /// <param name="values">The predicate values.</param>
 /// <returns>The current object, for call chaining.</returns>
 private static Predicate WithCondition(string field, PredicateOperator @operator,
     string[] values) {
   return new Predicate() {
     field = field,
     @operator = @operator,
     values = values
   };
 }
Beispiel #7
0
 public BinaryOpPredicate(Expr left, PredicateOperator op, Expr right)
 {
     this.Comments     = new Comments(1);
     this.Left         = left;
     this.Operator     = op;
     this.Right        = right;
     this.Left.Parent  = this;
     this.Right.Parent = this;
 }
Beispiel #8
0
 internal BinaryOpPredicate(Expr left, PredicateOperator op, Expr right, Comments comments)
 {
     this.Comments     = comments;
     this.Left         = left;
     this.Operator     = op;
     this.Right        = right;
     this.Left.Parent  = this;
     this.Right.Parent = this;
 }
Beispiel #9
0
 /// <summary>
 /// Adds a filter to select only items where the value of
 /// <paramref name="field"/> satisfies a particular condition.
 /// </summary>
 /// <param name="field">The field to filter on.</param>
 /// <param name="operator">The predicate operator.</param>
 /// <param name="values">The predicate values.</param>
 /// <returns>The current object, for call chaining.</returns>
 private static Predicate WithCondition(string field, PredicateOperator @operator,
                                        string[] values)
 {
     return(new Predicate()
     {
         field = field,
         @operator = @operator,
         values = values
     });
 }
 public SubQueryPredicate(Expr operand
                          , PredicateOperator operater
                          , QueryQuantifier quantifier
                          , IQuery query)
 {
     this.Comments   = new Comments(4);
     this.Operand    = operand;
     this.Operator   = operater;
     this.Quantifier = quantifier;
     this.Query      = query;
 }
 internal SubQueryPredicate(Expr operand
                            , PredicateOperator operater
                            , QueryQuantifier quantifier
                            , IQuery query
                            , Comments comments)
 {
     this.Comments   = comments;
     this.Operand    = operand;
     this.Operator   = operater;
     this.Quantifier = quantifier;
     this.Query      = query;
 }
        /// <summary>
        /// Adds a filter to select only items where the value of
        /// <paramref name="field"/> satisfies a particular condition.
        /// </summary>
        /// <param name="field">The field to filter on.</param>
        /// <param name="operator">The predicate operator.</param>
        /// <param name="values">The predicate values.</param>
        /// <returns>A new <see cref="Predicate"/> object that filters by specified
        /// conditions.</returns>
        private static Predicate WithCondition(string field, PredicateOperator @operator,
                                               string[] values)
        {
            // Mark the usage.
            featureUsageRegistry.MarkUsage(FEATURE_ID);;

            return(new Predicate()
            {
                field = field,
                @operator = @operator,
                values = values
            });
        }
Beispiel #13
0
        private bool FindPredicate(char use)
        {
            var regex = new Regex(@"[A-EG-SU-Z]");
            var match = regex.Match(use.ToString());

            if (match.Success)
            {
                var predicate = new PredicateOperator(_argumentManager);
                predicate.SetName(use);
                _operator = predicate;
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// 指定された条件式演算子を反転します。
        /// </summary>
        /// <param name="@operator">演算子</param>
        /// <returns>反転された演算子</returns>
        public static PredicateOperator Flip(this PredicateOperator @operator)
        {
            switch (@operator)
            {
            case PredicateOperator.LessThan:            return(PredicateOperator.GreaterThan);

            case PredicateOperator.LessThanOrEqual:     return(PredicateOperator.GreaterThanOrEqual);

            case PredicateOperator.GreaterThan:         return(PredicateOperator.LessThan);

            case PredicateOperator.GreaterThanOrEqual:  return(PredicateOperator.LessThanOrEqual);
            }
            return(@operator);
        }
Beispiel #15
0
        /// <summary>
        /// Creates the <see cref="PropertyFilter{T}"/>.
        /// </summary>
        /// <param name="propertyPath">The property path</param>
        /// <param name="operator">The operator</param>
        /// <param name="value">The value</param>
        /// <param name="culture">The culture</param>
        /// <param name="isCaseSensitive"></param>
        public PropertyFilter(string propertyPath, PredicateOperator @operator, object value, CultureInfo culture, bool isCaseSensitive)
        {
            if (propertyPath == null)
            {
                throw new ArgumentNullException(nameof(propertyPath));
            }

            this.builder         = new PredicateBuilder();
            this.propertyPath    = propertyPath;
            this.@operator       = @operator;
            this.value           = value;
            this.culture         = culture;
            this.isCaseSensitive = isCaseSensitive;
            this.Refresh();
        }
Beispiel #16
0
        /// <summary>
        /// Extends the specified source Predicate with another Predicate and the specified PredicateOperator.
        /// </summary>
        /// <typeparam name="T">The type</typeparam>
        /// <param name="first">The source Predicate.</param>
        /// <param name="second">The second Predicate.</param>
        /// <param name="operator">The Operator (can be "And" or "Or").</param>
        /// <returns>Expression{Func{T, bool}}</returns>
        public static Expression <Func <T, bool> > Extend <T>(
            this ExpressionStarter <T> first,
            Expression <Func <T, bool> > second,
            PredicateOperator @operator = PredicateOperator.Or)
        {
            if (first is null)
            {
                throw new ArgumentNullException(nameof(first));
            }
            if (second is null)
            {
                throw new ArgumentNullException(nameof(second));
            }

            return(@operator == PredicateOperator.Or ? first.Or(second) : first.And(second));
        }
        public Selector <TField> AddPredicate(TField field, PredicateOperator @operator, params object[] values)
        {
            var predicate = new Predicate();

            predicate.Field    = field.ToString();
            predicate.Operator = @operator;
            predicate.Values   = new List <string>();
            foreach (var value in values)
            {
                predicate.Values.Add(value.ToString());
            }
            if (Predicates == null)
            {
                Predicates = new List <Predicate>();
            }
            Predicates.Add(predicate);
            return(this);
        }
Beispiel #18
0
        // 演算子を反転させる、 <= と >= の違いを吸収するため
        public static PredicateOperator Flip(this PredicateOperator predicateOperator)
        {
            switch (predicateOperator)
            {
            case PredicateOperator.LessThan:
                return(PredicateOperator.GreaterThan);

            case PredicateOperator.LessThanOrEqual:
                return(PredicateOperator.GreaterThanOrEqual);

            case PredicateOperator.GreaterThan:
                return(PredicateOperator.LessThan);

            case PredicateOperator.GreaterThanOrEqual:
                return(PredicateOperator.LessThanOrEqual);

            default:
                return(predicateOperator);
            }
        }
Beispiel #19
0
            // 左右ノードから抽出
            PredicatePair ExtractBinary(BinaryExpression node, PredicateOperator predicateOperator)
            {
                // x.hoge == xx形式なら左がメンバ名
                var memberName = ExtractMemberName(node.Left);

                if (memberName != null)
                {
                    var value = GetValue(node.Right);
                    return(new PredicatePair(memberName, value, predicateOperator));
                }
                // xx == x.hoge形式なら右がメンバ名
                memberName = ExtractMemberName(node.Right);
                if (memberName != null)
                {
                    var value = GetValue(node.Left);
                    return(new PredicatePair(memberName, value, predicateOperator.Flip())); // >, >= と <, <= を統一して扱うため演算子は左右反転
                }

                throw new InvalidOperationException();
            }
        /// <summary>
        /// Adds a filter to select only items where the value of
        /// <paramref name="field"/> satisfies a particular condition.
        /// </summary>
        /// <param name="field">The field to filter on.</param>
        /// <param name="operator">The predicate operator.</param>
        /// <param name="values">The predicate values.</param>
        /// <returns>A new <see cref="Predicate"/> object that filters by specified
        /// conditions.</returns>
        private static Predicate WithCondition(string field, PredicateOperator @operator,
        string[] values)
        {
            // Mark the usage.
              featureUsageRegistry.MarkUsage(FEATURE_ID);

              return new Predicate() {
            field = field,
            @operator = @operator,
            values = values
              };
        }
Beispiel #21
0
 /// <summary>
 /// Creates the <see cref="PropertyFilter{T}"/>.
 /// </summary>
 /// <param name="propertyPath">The property path</param>
 /// <param name="operator">The operator</param>
 /// <param name="value">The value</param>
 /// <param name="isCaseSensitive"></param>
 public PropertyFilter(string propertyPath, PredicateOperator @operator, object value, bool isCaseSensitive)
     : this(propertyPath, @operator, value, null, isCaseSensitive)
 {
 }
Beispiel #22
0
 /// <summary>
 /// Creates the <see cref="PropertyFilter{T}"/>.
 /// </summary>
 /// <param name="propertyPath">The property path</param>
 /// <param name="operator">The operator</param>
 /// <param name="value">The value</param>
 public PropertyFilter(string propertyPath, PredicateOperator @operator, object value)
     : this(propertyPath, @operator, value, null, false)
 {
 }
Beispiel #23
0
        private IAsciiBasePropositionalOperator Process(IAsciiBasePropositionalOperator work)
        {
            var logic = work as IAsciiSinglePropositionalOperator;

            if (logic != null)
            {
                switch (logic.GetAsciiSymbol())
                {
                case '>':
                    var or = new OrPropositionalOperator(_manager);
                    or.Instantiate(new [] { SurroundWithNot(logic.GetChilds()[0]), logic.GetChilds()[1] });
                    return(HandleOr(or));

                case '=':
                    var implication1 = new IfThenPropositionalOperator(_manager);
                    implication1.Instantiate(new [] { logic.GetChilds()[0], logic.GetChilds()[1] });

                    var implication2 = new IfThenPropositionalOperator(_manager);
                    implication2.Instantiate(new IAsciiBasePropositionalOperator[] { logic.GetChilds()[1], logic.GetChilds()[0] });

                    var and = new AndPropositionalOperator(_manager);
                    and.Instantiate(new IAsciiBasePropositionalOperator[] { implication1, implication2 });
                    return(HandleAnd(and));

                case '&':
                    return(HandleAnd((AndPropositionalOperator)logic));

                case '|':
                    return(HandleOr((OrPropositionalOperator)logic));

                case '~':
                    return(logic);

                case '%':
                    var nAnd = new AndPropositionalOperator(_manager);
                    nAnd.Instantiate(logic.GetChilds());
                    return(SurroundWithNot(HandleAnd(nAnd)));

                case 'F':
                    return(new TruePropositionalOperator(_manager));

                case 'T':
                    return(new FalsePropositionalOperator(_manager));

                case '@':
                    if (work is UniversalQuantifierOperator workUnversal)
                    {
                        var ext = new ExtensionalQuantifierOperator(_manager);
                        ext.SetVariable(workUnversal.GetVariable());
                        ext.Instantiate(new[] { SurroundWithNot(logic.GetChilds()[0]) });
                        return(SurroundWithNot(ext));
                    }
                    break;

                case '!':
                    if (work is ExtensionalQuantifierOperator workExtensional)
                    {
                        var universal = new UniversalQuantifierOperator(_manager);
                        universal.SetVariable(workExtensional.GetVariable());
                        universal.Instantiate(new[] { SurroundWithNot(logic.GetChilds()[0]) });
                        return(SurroundWithNot(universal));
                    }
                    break;
                }
            }

            if (work is PredicateOperator predicate)
            {
                var result = new PredicateOperator(_manager);
                result.SetName(predicate.GetName());
                foreach (var child in work.GetChilds())
                {
                    result.AddChild(Process(child));
                }
                return(result);
            }

            if (work is ScalarPropositionalOperator scalar)
            {
                return(_manager.RequestOperator(scalar.GetName()));
            }
            throw new System.Exception("Operator not found");
        }
Beispiel #24
0
 public PredicatePair(string name, object value, PredicateOperator predicateOperator)
 {
     this.MemberName = name;
     this.Value      = value;
     this.Operator   = predicateOperator;
 }
Beispiel #25
0
 public Predicate(string fieldName, PredicateOperator op, Element value)
 {
     this.FieldName = fieldName;
     this.Operator = op;
     this.Value = value;
 }
Beispiel #26
0
 /// <summary>
 /// Creates the predicate expression.
 /// </summary>
 /// <typeparam name="T">The type</typeparam>
 /// <param name="propertyPath">The property path</param>
 /// <param name="operator">The operator</param>
 /// <param name="value">The value</param>
 /// <returns>The predicate expresion</returns>
 public Expression <Predicate <T> > CreatePredicateExpression <T>(string propertyPath, PredicateOperator @operator, object value)
 {
     return(CreatePredicateExpression <T>(propertyPath, @operator, value, CultureInfo.InvariantCulture, false));
 }
Beispiel #27
0
 /// <summary>
 /// Creates a Predicate with can be "And" (true) or "Or" (false).
 /// </summary>
 /// <typeparam name="T">The generic Type</typeparam>
 /// <param name="startOperator">The start PredicateOperator (can be "And" or "Or").</param>
 /// <returns>Expression{Func{T, bool}}</returns>
 public static Expression <Func <T, bool> > Create <T>(PredicateOperator startOperator = PredicateOperator.Or)
 {
     return(f => startOperator == PredicateOperator.And);
 }
        public override void ExitBinaryOpPredicate(MiniSqlParserParser.BinaryOpPredicateContext context)
        {
            var right    = (Expr)_stack.Pop();
            var comments = this.GetComments(context.op);
            var left     = (Expr)_stack.Pop();

            var opType           = context.op.Type;
            PredicateOperator op = PredicateOperator.Equal;

            if (opType == MiniSqlParserLexer.ASSIGN)
            {
                op = PredicateOperator.Equal;
            }
            else if (opType == MiniSqlParserLexer.NOT_EQ2)
            {
                op = PredicateOperator.NotEqual;
            }
            else if (opType == MiniSqlParserLexer.LT)
            {
                op = PredicateOperator.Less;
            }
            else if (opType == MiniSqlParserLexer.LT_EQ)
            {
                op = PredicateOperator.LessOrEqual;
            }
            else if (opType == MiniSqlParserLexer.GT)
            {
                op = PredicateOperator.Greater;
            }
            else if (opType == MiniSqlParserLexer.GT_EQ)
            {
                op = PredicateOperator.GreaterOrEqual;
            }
            else if (opType == MiniSqlParserLexer.EQ)
            {
                op = PredicateOperator.Equal2;
            }
            else if (opType == MiniSqlParserLexer.NOT_EQ1)
            {
                op = PredicateOperator.NotEqual2;
            }
            else if (opType == MiniSqlParserLexer.AT_LT)
            {
                op = PredicateOperator.ContainsJsonValueL;
            }
            else if (opType == MiniSqlParserLexer.AT_GT)
            {
                op = PredicateOperator.ContainsJsonValueR;
            }
            else if (opType == MiniSqlParserLexer.QRY_PIPE)
            {
                op = PredicateOperator.ExistsJsonValue2;
            }
            else if (opType == MiniSqlParserLexer.QRY_AMP)
            {
                op = PredicateOperator.ExistsJsonValue3;
            }
            else
            {
                throw new CannotBuildASTException("Undifined PredicateOperator is used");
            }

            var node = new BinaryOpPredicate(left, op, right, comments);

            _stack.Push(node);
        }
        public override void ExitSubQueryPredicate(MiniSqlParserParser.SubQueryPredicateContext context)
        {
            var comments = this.GetComments(context);

            var query = (IQuery)_stack.Pop();

            var             opType2    = context.op2.Type;
            QueryQuantifier quantifier = QueryQuantifier.Any;

            if (opType2 == MiniSqlParserLexer.K_ANY)
            {
                quantifier = QueryQuantifier.Any;
            }
            else if (opType2 == MiniSqlParserLexer.K_SOME)
            {
                quantifier = QueryQuantifier.Some;
            }
            else if (opType2 == MiniSqlParserLexer.K_ALL)
            {
                quantifier = QueryQuantifier.All;
            }
            else
            {
                throw new CannotBuildASTException("Undifined QueryQuantifier is used");
            }

            var opType1 = context.op1.Type;
            PredicateOperator operater = PredicateOperator.Equal;

            if (opType1 == MiniSqlParserLexer.ASSIGN)
            {
                operater = PredicateOperator.Equal;
            }
            else if (opType1 == MiniSqlParserLexer.NOT_EQ2)
            {
                operater = PredicateOperator.NotEqual;
            }
            else if (opType1 == MiniSqlParserLexer.LT)
            {
                operater = PredicateOperator.Less;
            }
            else if (opType1 == MiniSqlParserLexer.LT_EQ)
            {
                operater = PredicateOperator.LessOrEqual;
            }
            else if (opType1 == MiniSqlParserLexer.GT)
            {
                operater = PredicateOperator.Greater;
            }
            else if (opType1 == MiniSqlParserLexer.GT_EQ)
            {
                operater = PredicateOperator.GreaterOrEqual;
            }
            else if (opType1 == MiniSqlParserLexer.EQ)
            {
                operater = PredicateOperator.Equal2;
            }
            else if (opType1 == MiniSqlParserLexer.NOT_EQ1)
            {
                operater = PredicateOperator.NotEqual2;
            }
            else
            {
                throw new CannotBuildASTException("Undifined PredicateOperator is used");
            }

            var operand = (Expr)_stack.Pop();

            var node = new SubQueryPredicate(operand, operater, quantifier, query, comments);

            _stack.Push(node);
        }
Beispiel #30
0
        /// <summary>
        /// Creates the predicate expression.
        /// </summary>
        /// <typeparam name="T">The type</typeparam>
        /// <param name="propertyPath">The property </param>
        /// <param name="operator">The operator</param>
        /// <param name="value">The value</param>
        /// <param name="culture">The culture</param>
        /// <param name="isCaseSensitive">Checks if is case sensitive</param>
        /// <returns>The predicate expresion</returns>
        public Expression <Predicate <T> > CreatePredicateExpression <T>(string propertyPath, PredicateOperator @operator, object value, CultureInfo culture, bool isCaseSensitive)
        {
            if (propertyPath == null)
            {
                throw new ArgumentNullException(nameof(propertyPath));
            }

            // p => p.FirstName == "Marie"
            var parameterExpression = CreateParameter(typeof(T));                                                // Type
            var memberExpression    = CreateMember(parameterExpression, propertyPath);                           // property name

            value = TryConvert(memberExpression, value, culture);                                                // convert value ?

            var constantExpression = CreateConstant(value);                                                      // value

            var bodyExpression   = CreateBody(@operator, memberExpression, constantExpression, isCaseSensitive); // operator
            var lambdaExpression = Expression.Lambda <Predicate <T> >(bodyExpression, parameterExpression);

            return(lambdaExpression);
        }
Beispiel #31
0
 /// <summary>
 /// Creates the <see cref="PropertyFilter{T}"/>.
 /// </summary>
 /// <param name="propertyPath">The property path</param>
 /// <param name="operator">The operator</param>
 /// <param name="value">The value</param>
 /// <param name="culture">The culture</param>
 public PropertyFilter(string propertyPath, PredicateOperator @operator, object value, CultureInfo culture)
     : this(propertyPath, @operator, value, culture, false)
 {
 }
        /// <summary>
        /// Extends the specified source Predicate with another Predicate and the specified PredicateOperator.
        /// </summary>
        /// <typeparam name="T">The type</typeparam>
        /// <param name="first">The source Predicate.</param>
        /// <param name="second">The second Predicate.</param>
        /// <param name="op">The Operator (can be "And" or "Or").</param>
        /// <returns>Expression{Func{T, bool}}</returns>
        public static Expression <Func <T, bool> > Extend <T>(this Expression <Func <T, bool> > first, Expression <Func <T, bool> > second, PredicateOperator op = PredicateOperator.Or)
        {
            Guard.NotNull(first, nameof(first));
            Guard.NotNull(second, nameof(second));

            return(op == PredicateOperator.Or ? first.Or(second) : first.And(second));
        }
Beispiel #33
0
 public override string ToString()
 {
     return(PredicateOperator.GetAttributeDescription() + " " + PredicateOperand);
 }
Beispiel #34
0
        /// <summary>
        /// Creates the body <see cref="Expression"/>.
        /// </summary>
        /// <param name="operator">The operator</param>
        /// <param name="left">The left expression</param>
        /// <param name="right">The right expression</param>
        /// <param name="isCaseSensitive">Checks if is case sensitive</param>
        /// <returns>The expression created</returns>
        public Expression CreateBody(PredicateOperator @operator, Expression left, Expression right, bool isCaseSensitive)
        {
            // p.FirstName == "Marie"
            Expression expression = null;

            switch (@operator)
            {
            case PredicateOperator.IsEqual:
                expression = Expression.Equal(left, right);
                break;

            case PredicateOperator.IsLessThan:
                expression = Expression.LessThan(left, right);
                break;

            case PredicateOperator.IsGreaterThan:
                expression = Expression.GreaterThan(left, right);
                break;

            case PredicateOperator.IsGreaterThanOrEqualTo:
                expression = Expression.GreaterThanOrEqual(left, right);
                break;

            case PredicateOperator.IsLessThanOrEqualTo:
                expression = Expression.LessThanOrEqual(left, right);
                break;

            case PredicateOperator.IsNotEqual:
                expression = Expression.NotEqual(left, right);
                break;

            case PredicateOperator.StartsWith:
                if (isCaseSensitive)
                {
                    expression = Expression.Call(left, typeof(string).GetMethod("StartsWith", new Type[] { typeof(string) }), right);
                }
                else
                {
                    expression = Expression.Call(left, typeof(string).GetMethod("StartsWith", new Type[] { typeof(string), typeof(StringComparison) }),
                                                 right, Expression.Constant(StringComparison.InvariantCultureIgnoreCase));
                }
                break;

            case PredicateOperator.EndsWith:
                if (isCaseSensitive)
                {
                    expression = Expression.Call(left, typeof(string).GetMethod("EndsWith", new Type[] { typeof(string) }), right);
                }
                else
                {
                    expression = Expression.Call(left, typeof(string).GetMethod("EndsWith", new Type[] { typeof(string), typeof(StringComparison) }),
                                                 right, Expression.Constant(StringComparison.InvariantCultureIgnoreCase));
                }
                break;

            case PredicateOperator.Contains:
                if (isCaseSensitive)
                {
                    expression = Expression.Call(left, typeof(string).GetMethod("Contains", new Type[] { typeof(string) }), right);
                }
                else
                {
                    expression = Expression.GreaterThanOrEqual(Expression.Call(left, typeof(string).GetMethod("IndexOf", new Type[] { typeof(string), typeof(StringComparison) }),
                                                                               right, Expression.Constant(StringComparison.InvariantCultureIgnoreCase)), Expression.Constant(0));
                }
                break;

            case PredicateOperator.DoesNotContain:
                if (isCaseSensitive)
                {
                    expression = Expression.Not(Expression.Call(left, typeof(string).GetMethod("Contains", new Type[] { typeof(string) }), right));
                }
                else
                {
                    expression = Expression.Equal(Expression.Call(left, typeof(string).GetMethod("IndexOf", new Type[] { typeof(string), typeof(StringComparison) }),
                                                                  right, Expression.Constant(StringComparison.InvariantCultureIgnoreCase)), Expression.Constant(-1));
                }
                break;
            }
            return(expression);
        }