예제 #1
0
        protected static string esArithmeticOperatorToString(esMathmaticalExpression mathmaticalExpression)
        {
            switch (mathmaticalExpression.Operator)
            {
            case esArithmeticOperator.Add:

                // MEG - 4/26/08, I'm not thrilled with this check here, will revist on future release
                if (mathmaticalExpression.SelectItem1.Column.Datatype == esSystemType.String ||
                    (mathmaticalExpression.SelectItem1.HasMathmaticalExpression && mathmaticalExpression.SelectItem1.MathmaticalExpression.LiteralType == esSystemType.String) ||
                    (mathmaticalExpression.SelectItem1.HasMathmaticalExpression && mathmaticalExpression.SelectItem1.MathmaticalExpression.SelectItem1.Column.Datatype == esSystemType.String) ||
                    (mathmaticalExpression.LiteralType == esSystemType.String))
                {
                    return("||");
                }
                else
                {
                    return("+");
                }

            case esArithmeticOperator.Subtract: return(" - ");

            case esArithmeticOperator.Multiply: return(" * ");

            case esArithmeticOperator.Divide: return(" / ");

            case esArithmeticOperator.Modulo: return(" % ");

            default: return("");
            }
        }
예제 #2
0
        protected static string GetMathmaticalExpressionLiteralType(esMathmaticalExpression mathmaticalExpression)
        {
            switch (mathmaticalExpression.LiteralType)
            {
            case esSystemType.String:
                return(Delimiters.StringOpen + (string)mathmaticalExpression.Literal + Delimiters.StringClose);

            case esSystemType.DateTime:
                return(Delimiters.StringOpen + ((DateTime)(mathmaticalExpression.Literal)).ToShortDateString() + Delimiters.StringClose);

            default:
                return(Convert.ToString(mathmaticalExpression.Literal));
            }
        }
        protected static string GetMathmaticalExpressionColumn(esMathmaticalExpression mathmaticalExpression)
        {
            string sql = "(";

            if (mathmaticalExpression.ItemFirst)
            {
                sql += GetExpressionColumn(mathmaticalExpression.SelectItem1, true, true);
                sql += esArithmeticOperatorToString(mathmaticalExpression.Operator);

                if (mathmaticalExpression.SelectItem2 != null)
                {
                    sql += GetExpressionColumn(mathmaticalExpression.SelectItem2, true, true);
                }
                else
                {
                    sql += GetMathmaticalExpressionLiteralType(mathmaticalExpression);
                }
            }
            else
            {
                if (mathmaticalExpression.SelectItem2 != null)
                {
                    sql += GetExpressionColumn(mathmaticalExpression.SelectItem2, true, true);
                }
                else
                {
                    sql += GetMathmaticalExpressionLiteralType(mathmaticalExpression);
                }

                sql += esArithmeticOperatorToString(mathmaticalExpression.Operator);
                sql += GetExpressionColumn(mathmaticalExpression.SelectItem1, true, true);
            }

            sql += ")";

            return(sql);
        }
예제 #4
0
        protected static string GetMathmaticalExpressionColumn(StandardProviderParameters std, esDynamicQuerySerializable query, esMathmaticalExpression mathmaticalExpression)
        {
            string sql = "(";

            if (mathmaticalExpression.ItemFirst)
            {
                sql += GetExpressionColumn(std, query, mathmaticalExpression.SelectItem1, true, true);
                sql += esArithmeticOperatorToString(mathmaticalExpression.Operator);

                if (mathmaticalExpression.SelectItem2 != null)
                {
                    sql += GetExpressionColumn(std, query, mathmaticalExpression.SelectItem2, true, true);
                }
                else
                {
                    sql += GetMathmaticalExpressionLiteralType(std, mathmaticalExpression);
                }
            }
            else
            {
                if (mathmaticalExpression.SelectItem2 != null)
                {
                    sql += GetExpressionColumn(std, query, mathmaticalExpression.SelectItem2, true, true);
                }
                else
                {
                    sql += GetMathmaticalExpressionLiteralType(std, mathmaticalExpression);
                }

                sql += esArithmeticOperatorToString(mathmaticalExpression.Operator);
                sql += GetExpressionColumn(std, query, mathmaticalExpression.SelectItem1, true, true);
            }

            sql += ")";

            return(sql);
        }
        protected static string GetMathmaticalExpressionColumn(StandardProviderParameters std, esDynamicQuerySerializable query, esMathmaticalExpression mathmaticalExpression)
        {
            string sql = "(";

            if (mathmaticalExpression.ItemFirst)
            {
                sql += GetExpressionColumn(std, query, mathmaticalExpression.SelectItem1, true, true);

                switch (mathmaticalExpression.Operator)
                {
                case esArithmeticOperator.Add: sql += "+"; break;

                case esArithmeticOperator.Subtract: sql += "-"; break;

                case esArithmeticOperator.Multiply: sql += "*"; break;

                case esArithmeticOperator.Divide: sql += "/"; break;

                case esArithmeticOperator.Modulo: sql += "%"; break;
                }

                if (mathmaticalExpression.SelectItem2 != null)
                {
                    sql += GetExpressionColumn(std, query, mathmaticalExpression.SelectItem2, true, true);
                }
                else
                {
                    switch (mathmaticalExpression.LiteralType)
                    {
                    case esSystemType.String:
                        sql += Delimiters.StringOpen + (string)mathmaticalExpression.Literal + Delimiters.StringClose;
                        break;

                    case esSystemType.DateTime:
                        sql += Delimiters.StringOpen + ((DateTime)(mathmaticalExpression.Literal)).ToShortDateString() + Delimiters.StringClose;
                        break;

                    default:
                        sql += Convert.ToString(mathmaticalExpression.Literal);
                        break;
                    }
                }
            }
            else
            {
                if (mathmaticalExpression.SelectItem2 != null)
                {
                    sql += GetExpressionColumn(std, query, mathmaticalExpression.SelectItem2, true, true);
                }
                else
                {
                    switch (mathmaticalExpression.LiteralType)
                    {
                    case esSystemType.String:
                        sql += Delimiters.StringOpen + (string)mathmaticalExpression.Literal + Delimiters.StringClose;
                        break;

                    case esSystemType.DateTime:
                        sql += Delimiters.StringOpen + ((DateTime)(mathmaticalExpression.Literal)).ToShortDateString() + Delimiters.StringClose;
                        break;

                    default:
                        sql += Convert.ToString(mathmaticalExpression.Literal);
                        break;
                    }
                }

                switch (mathmaticalExpression.Operator)
                {
                case esArithmeticOperator.Add: sql += "+"; break;

                case esArithmeticOperator.Subtract: sql += "-"; break;

                case esArithmeticOperator.Multiply: sql += "*"; break;

                case esArithmeticOperator.Divide: sql += "/"; break;

                case esArithmeticOperator.Modulo: sql += "%"; break;
                }

                sql += GetExpressionColumn(std, query, mathmaticalExpression.SelectItem1, true, true);
            }

            sql += ")";

            return(sql);
        }
예제 #6
0
        protected static string GetMathmaticalExpressionColumn(StandardProviderParameters std, esDynamicQuery query, esMathmaticalExpression mathmaticalExpression)
        {
            bool isConcat = false;

            string sql = "(";

            if (mathmaticalExpression.ItemFirst)
            {
                sql += GetExpressionColumn(std, query, mathmaticalExpression.SelectItem1, true, false);
                sql += esArithmeticOperatorToString(mathmaticalExpression, out isConcat);

                if (mathmaticalExpression.SelectItem2 != null)
                {
                    sql += GetExpressionColumn(std, query, mathmaticalExpression.SelectItem2, true, false);
                }
                else
                {
                    sql += GetMathmaticalExpressionLiteralType(std, mathmaticalExpression);
                }
            }
            else
            {
                if (mathmaticalExpression.SelectItem2 != null)
                {
                    sql += GetExpressionColumn(std, query, mathmaticalExpression.SelectItem2, true, true);
                }
                else
                {
                    sql += GetMathmaticalExpressionLiteralType(std, mathmaticalExpression);
                }

                sql += esArithmeticOperatorToString(mathmaticalExpression, out isConcat);
                sql += GetExpressionColumn(std, query, mathmaticalExpression.SelectItem1, true, false);
            }

            sql += ")";

            if (isConcat)
            {
                sql = "CONCAT(" + sql.Substring(1, sql.Length - 2) + ")";
            }

            return(sql);
        }
예제 #7
0
        protected static string GetMathmaticalExpressionColumn(StandardProviderParameters std, esDynamicQuerySerializable query, esMathmaticalExpression mathmaticalExpression)
        {
            bool isMod         = false;
            bool needsRounding = false;

            string sql = "(";

            if (mathmaticalExpression.ItemFirst)
            {
                sql += GetExpressionColumn(std, query, mathmaticalExpression.SelectItem1, true, false);
                sql += esArithmeticOperatorToString(mathmaticalExpression, out isMod, out needsRounding);

                if (mathmaticalExpression.SelectItem2 != null)
                {
                    sql += GetExpressionColumn(std, query, mathmaticalExpression.SelectItem2, true, false);
                }
                else
                {
                    sql += GetMathmaticalExpressionLiteralType(std, mathmaticalExpression);
                }
            }
            else
            {
                if (mathmaticalExpression.SelectItem2 != null)
                {
                    sql += GetExpressionColumn(std, query, mathmaticalExpression.SelectItem2, true, true);
                }
                else
                {
                    sql += GetMathmaticalExpressionLiteralType(std, mathmaticalExpression);
                }

                sql += esArithmeticOperatorToString(mathmaticalExpression, out isMod, out needsRounding);
                sql += GetExpressionColumn(std, query, mathmaticalExpression.SelectItem1, true, false);
            }

            sql += ")";

            if (isMod)
            {
                sql = "MOD(" + sql.Replace("(", String.Empty).Replace(")", String.Empty) + ")";
            }
            if (needsRounding)
            {
                sql = "ROUND(" + sql + ", 10)";
            }

            return(sql);
        }