示例#1
0
        public override BaseLogicalExpression ToExpression()
        {
            BaseLogicalExpression expr = null;

            // Check if we need to change value type
            object parsedValue = Value;

            if (int.TryParse((string)parsedValue, out int intValue))
            {
                parsedValue = intValue;
            }
            else
            {
                // Strip single quotes from value
                parsedValue = Value.Replace("'", "");
            }

            switch (RelationalOperator)
            {
            case RelationalOperator.EQUAL:
                expr = new EqExpr(SimpleAttribute.value, parsedValue);
                break;

            case RelationalOperator.NOT_EQUAL:
                expr = new NeqExpr(SimpleAttribute.value, parsedValue);
                break;

            case RelationalOperator.GREATER_EQUAL:
                expr = new GteExpr(SimpleAttribute.value, parsedValue);
                break;

            case RelationalOperator.LESS_EQUAL:
                expr = new LteExpr(SimpleAttribute.value, parsedValue);
                break;

            case RelationalOperator.GREATER:
                expr = new GtExpr(SimpleAttribute.value, parsedValue);
                break;

            case RelationalOperator.LESS:
                expr = new LtExpr(SimpleAttribute.value, parsedValue);
                break;

            case RelationalOperator.LIKE:
            case RelationalOperator.IS:
                throw new NotSupportedException("Operation not supported");
            }

            return(expr);
        }
示例#2
0
        /// <summary>
        /// Creates a MatchOperator with inner Expr and EqExpr for the given fields
        /// </summary>
        /// <param name="SourceField"></param>
        /// <param name="TargetField"></param>
        /// <returns></returns>
        public static MatchOperator CreateLookupMatch(string SourceField, string TargetField)
        {
            EqExpr EqOp = new EqExpr($"${SourceField}", $"$${TargetField}");

            return(new MatchOperator(new Expr(EqOp)));
        }