예제 #1
0
        public ExpressionClip SubString(int start, int length)
        {
            ExpressionClip expr = ExpressionFactory.CreateCloneExpression(this);

            expr.Sql = ColumnFormatter.SubString(this.Sql, start, length);
            return(expr);
        }
예제 #2
0
        public static ExpressionClip operator %(ExpressionClip left, ExpressionClip right)
        {
            ExpressionClip expr = ExpressionFactory.CreateCloneExpression(left);

            ExpressionFactory.AppendExpression(expr, QueryOperator.Modulo, right);
            expr.dbType = DbType.Int32;
            return(expr);
        }
예제 #3
0
        public static ExpressionClip operator /(ExpressionClip left, object right)
        {
            ExpressionClip expr = ExpressionFactory.CreateCloneExpression(left);

            ExpressionFactory.AppendExpression(expr, QueryOperator.Divide,
                                               ExpressionFactory.CreateParameterExpression(left.dbType, right));
            return(expr);
        }
예제 #4
0
        public ExpressionClip Avg()
        {
            ExpressionClip expr = ExpressionFactory.CreateCloneExpression(this);

            expr.Sql = ColumnFormatter.Avg(this.Sql);

            return(expr);
        }
예제 #5
0
        public ExpressionClip BitwiseAnd(ExpressionClip right)
        {
            ExpressionClip expr = ExpressionFactory.CreateCloneExpression(this);

            ExpressionFactory.AppendExpression(expr, QueryOperator.BitwiseAND,
                                               right);

            return(expr);
        }
예제 #6
0
        public ExpressionClip Count(bool isDistinct)
        {
            ExpressionClip expr = ExpressionFactory.CreateCloneExpression(this);

            expr.Sql    = ColumnFormatter.Count(this.Sql, isDistinct);
            expr.dbType = DbType.Int32;

            return(expr);
        }
예제 #7
0
        public ExpressionClip GetDay()
        {
            ExpressionClip expr = ExpressionFactory.CreateCloneExpression(this);

            expr.Sql    = ColumnFormatter.DatePart(this.Sql, ColumnFormatter.DatePartType.Day);
            expr.dbType = DbType.Int32;

            return(expr);
        }
예제 #8
0
        public ExpressionClip BitwiseAnd(object right)
        {
            Check.Require(right != null, "right could not be null!");

            ExpressionClip expr = ExpressionFactory.CreateCloneExpression(this);

            ExpressionFactory.AppendExpression(expr, QueryOperator.BitwiseAND,
                                               ExpressionFactory.CreateParameterExpression(this.dbType, right));

            return(expr);
        }
예제 #9
0
        public ExpressionClip SubString(int start)
        {
            Check.Require(start >= 0, "start must >= 0!");

            ExpressionClip expr      = ExpressionFactory.CreateCloneExpression(this);
            ExpressionClip cloneExpr = ExpressionFactory.CreateCloneExpression(this);
            StringBuilder  sb        = new StringBuilder("SUBSTRING(");

            SqlQueryUtils.AppendColumnName(sb, this.Sql);
            sb.Append(',');
            sb.Append(start + 1);
            sb.Append(",LEN(");
            SqlQueryUtils.AppendColumnName(sb, cloneExpr.Sql);
            sb.Append(')');
            sb.Append(')');

            expr.sql = sb;
            SqlQueryUtils.AddParameters(expr.parameters, cloneExpr);

            return(expr);
        }
예제 #10
0
        public ExpressionClip IndexOf(string subString)
        {
            Check.Require(!string.IsNullOrEmpty(subString), "subString could not be null or empty!");

            ExpressionClip expr = ExpressionFactory.CreateCloneExpression(this);
            StringBuilder  sb   = new StringBuilder();

            sb.Append("CHARINDEX(");
            string paramName = MakeUniqueParamNameWithoutPrefixToken();

            sb.Append(paramName);
            sb.Append(',');
            SqlQueryUtils.AppendColumnName(sb, this.Sql);
            sb.Append(')');
            sb.Append("-1");

            expr.sql    = sb;
            expr.dbType = DbType.Int32;
            expr.parameters.Add(paramName, new KeyValuePair <DbType, object>(this.dbType, subString));

            return(expr);
        }