コード例 #1
0
ファイル: WhereClip.cs プロジェクト: Oman/Maleos
        public WhereClip Or(ExpressionClip left, QueryOperator op, ExpressionClip right)
        {
            bool toWrapBrackets = false;

            string sqlStr = left.Sql;
            while (sqlStr.IndexOf("] [") > 0)
                sqlStr = sqlStr.Substring(sqlStr.IndexOf("] [") + 2);
            left.Sql = sqlStr;

            if (sql.Length > 0)
            {
                sql.Append(" OR ");
                toWrapBrackets = true;
            }
            this.sql.Append(SqlQueryUtils.ToString(left));
            this.sql.Append(SqlQueryUtils.ToString(op));
            this.sql.Append(SqlQueryUtils.ToString(right));

            SqlQueryUtils.AddParameters(this.parameters, left);
            SqlQueryUtils.AddParameters(this.parameters, right);

            if (toWrapBrackets)
                this.sql = new StringBuilder("(" + this.sql.ToString() + ")");

            return this;
        }
コード例 #2
0
ファイル: ExpressionClip.cs プロジェクト: Oman/Maleos
        public virtual object Clone()
        {
            ExpressionClip newExpr = new ExpressionClip();
            newExpr.dbType = this.dbType;
            string tempSql = this.sql.ToString();

            Dictionary<string, KeyValuePair<DbType, object>>.Enumerator en = this.parameters.GetEnumerator();
            while (en.MoveNext())
            {
                object value = en.Current.Value.Value;
                if (value != null && value != DBNull.Value && value is ICloneable)
                {
                    value = ((ICloneable)value).Clone();
                }

                string newParamName = MakeUniqueParamNameWithoutPrefixToken();
                tempSql = tempSql.Replace('@' + en.Current.Key.TrimStart("@:?".ToCharArray()), '@' + newParamName);
                newExpr.Parameters.Add('@' + newParamName, new KeyValuePair<DbType, object>(en.Current.Value.Key, value));
            }
            newExpr.sql.Append(tempSql);
            return newExpr;
        }
コード例 #3
0
ファイル: ExpressionClip.cs プロジェクト: Oman/Maleos
        public WhereClip NotIn(ExpressionClip subQuery)
        {
            Check.Require(!ExpressionClip.IsNullOrEmpty(subQuery), "subQuery could not be null or empty.");

            WhereClip where = new WhereClip();
            where.Sql = string.Format("{0} NOT IN ({1})", this.ToString(), subQuery.ToString());
            if (subQuery.Parameters.Count > 0)
            {
                Dictionary<string, KeyValuePair<DbType, object>>.Enumerator en = subQuery.Parameters.GetEnumerator();
                while (en.MoveNext())
                {
                    where.Parameters.Add('@' + en.Current.Key.TrimStart("@:?".ToCharArray()), new KeyValuePair<DbType, object>(en.Current.Value.Key, en.Current.Value.Value));
                }
            }
            return where;
        }
コード例 #4
0
ファイル: ExpressionClip.cs プロジェクト: Oman/Maleos
 public ExpressionClip Append(QueryOperator op, ExpressionClip right)
 {
     this.sql.Append(SqlQueryUtils.ToString(op));
     this.sql.Append(SqlQueryUtils.ToString(right));
     SqlQueryUtils.AddParameters(this.parameters, right);
     return this;
 }
コード例 #5
0
ファイル: ExpressionClip.cs プロジェクト: Oman/Maleos
        public ExpressionClip BitwiseXOr(ExpressionClip right)
        {
            ExpressionClip expr = (ExpressionClip)this.Clone();
            expr.Append(QueryOperator.BitwiseXOR,
                right);

            return expr;
        }
コード例 #6
0
ファイル: ExpressionClip.cs プロジェクト: Oman/Maleos
 public static bool IsNullOrEmpty(ExpressionClip expr)
 {
     return ((object)expr) == null || expr.sql.Length == 0;
 }
コード例 #7
0
ファイル: ExpressionClip.cs プロジェクト: Oman/Maleos
 public static ExpressionClip GetCurrentUtcDate()
 {
     ExpressionClip expr = new ExpressionClip();
     expr.Sql = ColumnFormatter.GetCurrentUtcDate();
     expr.dbType = DbType.DateTime;
     return expr;
 }
コード例 #8
0
ファイル: ExpressionClip.cs プロジェクト: Oman/Maleos
 public static ExpressionClip operator /(object left, ExpressionClip right)
 {
     ExpressionClip expr = new ExpressionClip(right.dbType, left);
     expr.Append(QueryOperator.Divide, right);
     return expr;
 }
コード例 #9
0
ファイル: ExpressionClip.cs プロジェクト: Oman/Maleos
 public static ExpressionClip operator %(object left, ExpressionClip right)
 {
     ExpressionClip expr = new ExpressionClip(right.dbType, left);
     expr.Append(QueryOperator.Modulo, right);
     expr.dbType = DbType.Int32;
     return expr;
 }
コード例 #10
0
ファイル: ExpressionClip.cs プロジェクト: Oman/Maleos
 public static ExpressionClip operator !(ExpressionClip left)
 {
     ExpressionClip expr = new ExpressionClip().Append(QueryOperator.BitwiseNOT,
         left);
     return expr;
 }