Пример #1
0
        public override string AsString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("(");
            sb.Append(LeftExpression.ToString());
            switch (BinaryOperator)
            {
            case ExpressionBinaryOperator.AND: sb.Append(" AND "); break;

            case ExpressionBinaryOperator.OR: sb.Append(" OR "); break;

            case ExpressionBinaryOperator.EQUALS: sb.Append(" EQUALS "); break;

            case ExpressionBinaryOperator.NOTEQUALS: sb.Append(" NOTEQUALS "); break;

            case ExpressionBinaryOperator.LESSTHAN: sb.Append(" LESSTHAN "); break;

            case ExpressionBinaryOperator.GREATERTHAN: sb.Append(" GREATERTHAN "); break;

            case ExpressionBinaryOperator.PLUS: sb.Append(" PLUS "); break;

            case ExpressionBinaryOperator.MINUS: sb.Append(" MINUS "); break;

            case ExpressionBinaryOperator.TIMES: sb.Append(" TIMES "); break;

            case ExpressionBinaryOperator.DIVIDEDBY: sb.Append(" DIVIDEDBY "); break;
            }
            sb.Append(RightExpression.ToString());
            sb.Append(")");
            return(sb.ToString());
        }
Пример #2
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("(")
            .Append(LeftExpression.ToString()).Append(" ")
            .Append(Operator).Append(" ")
            .Append(RightExpression.ToString()).Append(")");
            return(sb.ToString());
        }
Пример #3
0
                public override string ToString()
                {
                    var sb = new StringBuilder("");

                    sb.Append("(");
                    sb.Append(LeftExpression.ToString());
                    sb.Append(" && ");
                    sb.Append(RightExpression.ToString());
                    sb.Append(")");
                    return(sb.ToString());
                }
Пример #4
0
        /// <summary>
        /// Outputs user-friendly representation string.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            string opString;

            switch (Operator)
            {
            case BinaryOperator.Add: opString = "+"; break;

            case BinaryOperator.And: opString = "AND"; break;

            case BinaryOperator.Contains: opString = "~"; break;

            case BinaryOperator.Div: opString = "DIV"; break;

            case BinaryOperator.DoesNotContain: opString = "!~"; break;

            case BinaryOperator.Equals: opString = "="; break;

            case BinaryOperator.GreaterThan: opString = ">"; break;

            case BinaryOperator.GreaterThanEquals: opString = ">="; break;

            case BinaryOperator.In: opString = "IN"; break;

            case BinaryOperator.Is: opString = "IS"; break;

            case BinaryOperator.LessThan: opString = "<"; break;

            case BinaryOperator.LessThanEquals: opString = "<="; break;

            case BinaryOperator.Mod: opString = "MOD"; break;

            case BinaryOperator.Mul: opString = "*"; break;

            case BinaryOperator.NotEquals: opString = "!="; break;

            case BinaryOperator.NotIn: opString = "NOT IN"; break;

            case BinaryOperator.Or: opString = "OR"; break;

            case BinaryOperator.Sub: opString = "-"; break;

            default: throw new InvalidOperationException("Unhandled operator: " + Operator);
            }
            return($"{LeftExpression.ToString()} {opString} {RightExpression.ToString()}");
        }
Пример #5
0
 public override string ToString()
 {
     return(LeftExpression.ToString() + this.operatorToString(this.Operator) + RightExpression.ToString());
 }
Пример #6
0
        protected override void Build()
        {
            // If for that is null.
            if (LeftExpression == null)
            {
                LeftExpression = string.Empty;
            }
            if (RightExpression == null)
            {
                RightExpression = string.Empty;
            }

            // Enclosing.
            if (LeftExpression != null && LeftExpression is Query)
            {
                ((QuerySegment)LeftExpression).Enclosed = true;
            }
            if (RightExpression != null && RightExpression is Query)
            {
                ((QuerySegment)RightExpression).Enclosed = true;
            }

            // If query condition constructor.
            if (LeftExpression is QueryCondition && RightExpression is QueryCondition)
            {
                // Query conditions.
                QueryCondition leftCondition  = LeftExpression as QueryCondition;
                QueryCondition rightCondition = RightExpression as QueryCondition;

                // Build.
                if (Enclosed)
                {
                    Text = "(" + leftCondition.ToString() + Query.ToSqlOperator(QueryOperator) + rightCondition.ToString() + ")";
                }
                else
                {
                    Text = leftCondition.ToString() + Query.ToSqlOperator(QueryOperator) + rightCondition.ToString();
                }
            }

            // Novo testirati.
            //else if (LeftExpression is Query && RightExpression is Query)
            //{

            //}
            else
            {
                // Build.
                if (Enclosed)
                {
                    Text = "(" + LeftExpression.ToString() + Query.ToSqlOperator(QueryOperator) + RightExpression.ToString() + ")";
                }
                else
                {
                    Text = LeftExpression.ToString() + Query.ToSqlOperator(QueryOperator) + RightExpression.ToString();
                }
            }

            // Set builded true.
            Builded = true;
        }
Пример #7
0
 public override string ToString() => $"{LeftExpression.ToString()} {Op.ToString()} {RightExpression.ToString()}";