Esempio n. 1
0
        public string ToString(Boolean FullFraction)
        {
            if (!FullFraction && Denominator > uint.MaxValue)
            {
                return("e^" + ExpValue.ToString());
            }
            Boolean d1 = Denominator == 1;

            return((d1 ? "" : "(") + Numerator.ToString("n0") + (d1 ? "" : "/" + Denominator.ToString("n0") + ")"));
        }
Esempio n. 2
0
        /// <summary>
        /// 转换为ESQL
        /// </summary>
        /// <returns></returns>
        public string ToESQLString(string TableName)
        {
            string FieldName = this.ExpName;

            if ((this.ConditionList.Count == 0) && (FieldName != null) && (FieldName == ""))
            {
                return("");
            }

            string ESQL = "";

            if ((FieldName != null) && (FieldName != ""))
            {
                //{0}  ??  {1} ;
                ESQL = ConvertOperatorToESQL();

                if (FieldName.ToUpper().IndexOf(TableName.ToUpper() + ".") == -1)
                {
                    //增加表名;
                    FieldName = TableName + "." + FieldName;
                }

                if (ExpValue == null || ExpValue == DBNull.Value || ExpValue.ToString().ToLower().Trim() == "null")
                {
                    // NULL 值处理 = 和 is 不需要处理,linqTOsql会自动处理 = 和 is的;
                    ExpValue = "null";
                    ESQL     = string.Format(ESQL, FieldName, ExpValue);
                }
                else if (ExpValue is string)
                {
                    //字符串
                    string ValueString = ExpValue.ToString();
                    if ((ExpOperater != eConditionOperator.In) && (ExpOperater != eConditionOperator.NotIn))
                    {
                        ValueString = "'" + ValueString + "'";
                    }
                    else
                    {
                        if (!ValueString.ToLower().Contains("select"))//非子表的查询
                        {
                            ValueString = "{" + ValueString + "}";
                        }
                    }
                    ESQL = string.Format(ESQL, FieldName, ValueString);
                }
                else if (ExpValue is DateTime)
                {
                    //日期
                    string ValueString = "DATETIME'" + ((DateTime)ExpValue).ToString("yyyy-MM-dd HH:mm:ss.fffffff") + "'";
                    ESQL = string.Format(ESQL, FieldName, ValueString);
                }
                else if (ExpValue is ValueType)
                {
                    //数值
                    ESQL = string.Format(ESQL, FieldName, ExpValue);
                }
                else if (ExpValue is Array)
                {
                    //对于IN 的,必须采用Array传入对象;
                    //待处理;
                }
                else
                {
                    ESQL = string.Format(ESQL, FieldName, ExpValue);
                }
            }

            if (ESQL != "")
            {
                if (ExpLogical == eLogicalOperator.And)
                {
                    ESQL = " AND " + ESQL;
                }
                if (ExpLogical == eLogicalOperator.Or)
                {
                    ESQL = " OR " + ESQL;
                }
            }

            string ChildESQL = "";

            foreach (ConditionExpression ce in this.ConditionList)
            {
                ChildESQL = ChildESQL + ce.ToESQLString(TableName);
            }
            if (ChildESQL != "")
            {
                if (ChildESQL.ToUpper().Trim().StartsWith("AND"))
                {
                    ChildESQL = ChildESQL.Trim().Remove(0, 3);
                }
                if (ChildESQL.ToUpper().Trim().StartsWith("OR"))
                {
                    ChildESQL = ChildESQL.Trim().Remove(0, 2);
                }

                if (ChildESQL != "")
                {
                    if (ExpLogical == eLogicalOperator.And)
                    {
                        ChildESQL = " AND ( " + ChildESQL + " ) ";
                    }
                    if (ExpLogical == eLogicalOperator.Or)
                    {
                        ChildESQL = " or ( " + ChildESQL + " ) ";
                    }
                }
                return(ChildESQL);
                //return " AND ( " + ChildESQL + " ) ";
            }

            ESQL = ESQL + ChildESQL;
            return(ESQL);
        }