Exemplo n.º 1
0
        /// <summary>Определение параметра</summary>
        public static Expr Param(string paramName)
        {
            Expr oper = new Expr();

            oper.Expression = OmExpression.Parameter(paramName);
            return(oper);
        }
Exemplo n.º 2
0
        /// <summary>Определение проверки на NULL</summary>
        public static Expr IfNull(Expr test, Expr val)
        {
            Expr oper = new Expr();

            oper.Expression = OmExpression.IfNull(test.Expression, val.Expression);
            return(oper);
        }
Exemplo n.º 3
0
        /// <summary>Определение функции</summary>
        public static Expr Function(AggFunc func, Expr val)
        {
            Expr oper = new Expr();

            oper.Expression = OmExpression.Function(func, val.Expression);
            return(oper);
        }
Exemplo n.º 4
0
        /// <summary>Определение поля</summary>
        public static Expr Field(string fieldName, From from)
        {
            Expr oper = new Expr();

            oper.Expression = OmExpression.Field(fieldName, from != null ? from.Term : null);
            return(oper);
        }
Exemplo n.º 5
0
        /// <summary>Определение константы (DateTime)</summary>
        public static Expr Date(DateTime val)
        {
            Expr oper = new Expr();

            oper.Expression = OmExpression.Date(val);
            return(oper);
        }
Exemplo n.º 6
0
        /// <summary>Произвольный SQL кон</summary>
        public static Expr Raw(string sqlText)
        {
            Expr oper = new Expr();

            oper.Expression = OmExpression.Raw(sqlText);
            return(oper);
        }
Exemplo n.º 7
0
        /// <summary>Определение поля</summary>
        public static Expr Field(string fieldName)
        {
            Expr oper = new Expr();

            oper.Expression = OmExpression.Field(fieldName);
            return(oper);
        }
Exemplo n.º 8
0
        /// <summary>Определение константы (string)</summary>
        public static Expr String(string val)
        {
            Expr oper = new Expr();

            oper.Expression = OmExpression.String(val);
            return(oper);
        }
Exemplo n.º 9
0
        /// <summary>Определение подзапроса</summary>
        public static Expr SubQuery(Select subQuery)
        {
            Expr oper = new Expr();

            oper.Expression = OmExpression.SubQuery(subQuery.Query);
            return(oper);
        }
Exemplo n.º 10
0
        /// <summary>Определение константы (double)</summary>
        public static Expr Num(double val)
        {
            Expr oper = new Expr();

            oper.Expression = OmExpression.Number(val);
            return(oper);
        }
Exemplo n.º 11
0
        /// <summary>Определение константы</summary>
        internal static Expr Constant(DataType type, object val)
        {
            Expr oper = new Expr();

            oper.Expression = OmExpression.Constant(type, val);
            return(oper);
        }
Exemplo n.º 12
0
        /// <summary>Определение NULL</summary>
        public static Expr Null()
        {
            Expr oper = new Expr();

            oper.Expression = OmExpression.Null();
            return(oper);
        }
Exemplo n.º 13
0
        static Cond CreateNotLikeCompare(OmExpression expr1, OmExpression expr2, char escapeChar)
        {
            Cond oper = new Cond();

            oper.Term = WhereTerm.CreateNotLikeCompare(expr1, expr2, escapeChar);
            return(oper);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Renders IfNull OmExpression
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="expr"></param>
 protected override void IfNull(StringBuilder builder, OmExpression expr)
 {
     builder.Append("isnull(");
     Expression(builder, expr.SubExpr1);
     builder.Append(", ");
     Expression(builder, expr.SubExpr2);
     builder.Append(")");
 }
Exemplo n.º 15
0
        /// <summary>
        /// Renders OmExpression
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="expr"></param>
        protected virtual void Expression(StringBuilder builder, OmExpression expr)
        {
            OmExpressionType type = expr.Type;

            if (type == OmExpressionType.Field)
            {
                QualifiedIdentifier(builder, expr.TableAlias, expr.Value.ToString());
            }
            else if (type == OmExpressionType.Function)
            {
                Function(builder, expr.AggFunction, expr.SubExpr1);
            }
            else if (type == OmExpressionType.Constant)
            {
                Constant(builder, (OmConstant)expr.Value);
            }
            else if (type == OmExpressionType.SubQueryText)
            {
                builder.AppendFormat("({0})", (string)expr.Value);
            }
            else if (type == OmExpressionType.SubQueryObject)
            {
                builder.AppendFormat("({0})", RenderSelect((SelectQuery)expr.Value));
            }
            else if (type == OmExpressionType.PseudoField)
            {
                builder.AppendFormat("{0}", (string)expr.Value);
            }
            else if (type == OmExpressionType.Parameter)
            {
                builder.AppendFormat("{0}{1}", ParameterPrefix, (string)expr.Value);
            }
            else if (type == OmExpressionType.Raw)
            {
                builder.AppendFormat("{0}", (string)expr.Value);
            }
            else if (type == OmExpressionType.Case)
            {
                CaseClause(builder, expr.CaseClause);
            }
            else if (type == OmExpressionType.IfNull)
            {
                IfNull(builder, expr);
            }
            else if (type == OmExpressionType.Null)
            {
                builder.Append("null");
            }
            else
            {
                throw new InvalidQueryException("Unkown expression type: " + type.ToString());
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// Renders IfNull OmExpression
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="expr"></param>
 protected abstract void IfNull(StringBuilder builder, OmExpression expr);
Exemplo n.º 17
0
 /// <summary>
 /// Renders a OmExpression of type Function
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="func"></param>
 /// <param name="param"></param>
 protected virtual void Function(StringBuilder builder, AggFunc func, OmExpression param)
 {
     builder.AppendFormat("{0}(", func.ToStringFast());            // .ToString());
     Expression(builder, param);
     builder.AppendFormat(")");
 }