Exemple #1
0
        /// <summary>
        /// Creates a return statement with value in this script
        /// </summary>
        /// <param name="clause"></param>
        /// <returns></returns>
        public DBStatement Return(DBClause clause)
        {
            DBReturn ret = DBReturn.Return(clause);

            this.Then(ret);
            return(ret);
        }
Exemple #2
0
        public DBUpdateQuery OrWhere(string owner, string table, string field, Compare op, DBClause right)
        {
            _where = _where.Or(owner, table, field, op, right);
            _last  = _where;

            return(this);
        }
Exemple #3
0
        /// <summary>
        /// Appends a new INNER JOIN between this table an the specified clause matching with the specified comparison
        /// </summary>
        /// <param name="foreign"></param>
        /// <param name="compare"></param>
        /// <returns></returns>
        public DBJoin InnerJoin(DBClause foreign, DBComparison compare)
        {
            DBJoin join = DBJoin.InnerJoin(foreign, compare);

            this.Joins.Add(join);
            return(join);
        }
        //
        // ctor(s)
        //

        #region protected DBCreateTableQuery(string owner, string name)

        /// <summary>
        /// protected constructor. Use the static factory
        /// methods to create and instance of this class
        /// </summary>
        /// <param name="table"></param>
        protected DBCreateTableQuery(string owner, string name)
        {
            this.TableName  = name;
            this.TableOwner = owner;
            this.Columns    = new DBColumnList();
            this._last      = null;
        }
        /// <summary>
        /// Appends an OR restriction to this sub selectes last JOIN statements
        /// </summary>
        /// <param name="reference"></param>
        /// <returns></returns>
        public DBClause Or(DBClause reference)
        {
            IDBBoolean join = (IDBBoolean)this.Joins[this.Joins.Count - 1];

            join.Or(reference);
            return((DBClause)join);
        }
Exemple #6
0
        /// <summary>
        /// Appends a new INNER JOIN between this table an the specified table matching between this tables parentfield and the other tables child field
        /// </summary>
        /// <param name="table"></param>
        /// <param name="parentField"></param>
        /// <param name="childField"></param>
        /// <returns></returns>
        public DBJoin InnerJoin(DBTable table, DBClause parentField, DBClause childField)
        {
            DBJoin join = DBJoin.InnerJoin(table, parentField, childField, Compare.Equals);

            this.Joins.Add(join);
            return(join);
        }
Exemple #7
0
        public DBUpdateQuery AndWhere(string table, string field, Compare op, DBClause right)
        {
            _where = _where.And(table, field, op, right);
            _last  = _where;

            return(this);
        }
Exemple #8
0
        public DBTableSet On(DBClause parent, Compare comp, DBClause child)
        {
            DBComparison compare = DBComparison.Compare(parent, comp, child);

            this.Last = this.Root.On(compare);
            return(this);
        }
        /// <summary>
        ///  Creates and returns a new DBQueryHintOption with the specified option value and value clause
        /// </summary>
        /// <param name="option"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static DBQueryHintOption QueryOption(DBQueryOption option, DBClause value)
        {
            DBQueryHintOption hint = QueryOption(option);

            hint.Clause = value;
            return(hint);
        }
Exemple #10
0
        /// <summary>
        /// Appends a new RIGHT OUTER JOIN between this table an the specified clause matching on the comparison
        /// </summary>
        /// <param name="foreign"></param>
        /// <param name="compare"></param>
        /// <returns></returns>
        public DBJoin RightJoin(DBClause foreign, DBComparison compare)
        {
            DBJoin join = DBJoin.Join(foreign, JoinType.RightOuter, compare);

            this.Joins.Add(join);
            return(join);
        }
Exemple #11
0
        /// <summary>
        /// Creates and returns a new RETURN xxx statement
        /// </summary>
        /// <param name="toreturn">The clause that will be executed by the database and its resultant value returned</param>
        /// <returns></returns>
        public static DBReturn Return(DBClause toreturn)
        {
            DBReturnRef ret = new DBReturnRef();

            ret.ToReturn = toreturn;
            return(ret);
        }
Exemple #12
0
        public DBUpdateQuery OrWhere(DBClause left, Compare op, DBClause right)
        {
            _where = _where.Or(left, op, right);
            _last  = _where;

            return(this);
        }
Exemple #13
0
        public static DBSelectSet SelectAggregate(AggregateFunction funct, DBClause field)
        {
            DBAggregate agg = DBAggregate.Aggregate(funct, field);
            DBSelectSet sel = DBSelectSet.Select(agg);

            sel.Last = agg;
            return(sel);
        }
Exemple #14
0
        //
        // Statement Factory methods
        //

        #region internal DBClause Aggregate(AggregateFunction func, DBClause dbref)

        internal DBClause Aggregate(AggregateFunction func, DBClause dbref)
        {
            DBAggregate agg = DBAggregate.Aggregate(func, dbref);

            this.Last = agg;
            this.Groupings.Add(agg);
            return(this);
        }
Exemple #15
0
        /// <summary>
        /// Begins a new SELECT statement with the clause as the first value returned.
        /// </summary>
        /// <param name="clause">Any valid SQL clause (DBConst, DBParam, etc.) </param>
        /// <returns>A new DBSelectQuery to support statement chaining</returns>
        public static DBSelectQuery Select(DBClause clause)
        {
            DBSelectQuery q = new DBSelectQuery();

            q.SelectSet = DBSelectSet.Select(clause);
            q.Last      = q.SelectSet;
            return(q);
        }
Exemple #16
0
        public DBClause Aggregate(AggregateFunction func, DBClause dbref)
        {
            DBAggregate agg = DBAggregate.Aggregate(func, dbref);

            this.Last = agg;
            this.Results.Add(agg);
            return(this);
        }
        /// <summary>
        /// Creates an unary NOT comparison
        /// </summary>
        /// <param name="clause"></param>
        /// <returns></returns>
        public static DBComparison Not(DBClause clause)
        {
            DBUnaryComparisonRef un = new DBUnaryComparisonRef();

            un.UnaryOperator = UnaryOp.Not;
            un.ToOperateOn   = clause;
            return(un);
        }
Exemple #18
0
        //
        // static factory methods
        //

        #region public static DBOrder OrderBy(Order order, DBClause clause)
        /// <summary>
        /// Creates a new OrderBy clause
        /// </summary>
        /// <param name="order"></param>
        /// <param name="clause"></param>
        /// <returns></returns>
        public static DBOrder OrderBy(Order order, DBClause clause)
        {
            DBOrderRef orderC = new DBOrderRef();

            orderC.Order  = order;
            orderC.Clause = clause;
            return(orderC);
        }
Exemple #19
0
        /// <summary>
        /// Appends a new [type] JOIN between this table an the specified clause matching on the comparison
        /// </summary>
        /// <param name="table"></param>
        /// <param name="type"></param>
        /// <param name="comp"></param>
        /// <returns></returns>
        public DBJoin Join(DBClause table, JoinType type, DBComparison comp)
        {
            DBJoin join = DBJoin.Join(table, type, comp);

            this.Joins.Add(join);

            return(join);
        }
Exemple #20
0
        public static DBSelectSet Select(DBClause fref)
        {
            DBSelectSet set = Select();

            set.Results.Add(fref);
            set.Last = fref;
            return(set);
        }
Exemple #21
0
        /// <summary>
        /// Creates a new JOIN of the specified type with no comparison
        /// </summary>
        /// <param name="jointo"></param>
        /// <param name="joinType"></param>
        /// <returns></returns>
        public static DBJoin Join(DBClause jointo, JoinType joinType)
        {
            DBJoinRef join = new DBJoinRef();

            join.JoinedTo = jointo;
            join.JoinType = joinType;
            return(join);
        }
Exemple #22
0
        internal static DBAssignSet Set(DBClause assignment)
        {
            DBAssignSet set = new DBAssignSet();

            set.Last = assignment;
            set.Assignments.Add(assignment);
            return(set);
        }
Exemple #23
0
        /// <summary>
        /// Adds an INNER JOIN from the results of this sub query to a second foreign clause.
        /// Use the ON method to add restrictions
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public DBJoin InnerJoin(DBClause table)
        {
            DBJoin join = DBJoin.Join(table, JoinType.InnerJoin);

            this.Joins.Add(join);

            return(join);
        }
Exemple #24
0
        //
        // static factory methods
        //

        #region public static DBAssign Set(DBClause item, DBClause toValue)

        /// <summary>
        /// Creates a new Assignment clause
        /// </summary>
        /// <param name="item"></param>
        /// <param name="toValue"></param>
        /// <returns></returns>
        public static DBAssign Set(DBClause item, DBClause toValue)
        {
            DBAssignRef aref = new DBAssignRef();

            aref._item  = item;
            aref._toval = toValue;

            return(aref);
        }
        /// <summary>
        /// Creates an EXISTS comparison
        /// </summary>
        /// <param name="clause"></param>
        /// <returns></returns>
        public static DBComparison Exists(DBClause clause)
        {
            DBUnaryComparisonRef un = new DBUnaryComparisonRef();

            un.UnaryOperator = Tech.Data.UnaryOp.Exists;
            un.ToOperateOn   = clause;

            return(un);
        }
Exemple #26
0
        internal static DBGroupBySet GroupBy(DBClause clause)
        {
            DBGroupBySet grp = GroupBy();

            grp.Groupings.Add(clause);
            grp.Last = clause;

            return(grp);
        }
Exemple #27
0
        public DBUpdateQuery Where(DBComparison compare)
        {
            DBFilterSet fs = DBFilterSet.Where(compare);

            this._where = fs;
            this._last  = fs;

            return(this);
        }
Exemple #28
0
        //
        // Where... methods
        //

        #region public DBUpdateQuery Where(DBClause left, Compare compare, DBClause right) + 1 overload

        public DBUpdateQuery Where(DBClause left, Compare compare, DBClause right)
        {
            DBFilterSet fs = DBFilterSet.Where(left, compare, right);

            this._where = fs;
            this._last  = fs;

            return(this);
        }
        //
        // static factory method(s)
        //

        #region public static DBBooleanOp Compare(DBClause left, BooleanOp op, DBClause right)

        /// <summary>
        /// Creates a new DBBooleanOp to compare the left and right clauses using the specified boolean operator
        /// </summary>
        /// <param name="left"></param>
        /// <param name="op"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static DBBooleanOp Compare(DBClause left, BooleanOp op, DBClause right)
        {
            DBBooleanOpRef oref = new DBBooleanOpRef();

            oref.Left     = left;
            oref.Right    = right;
            oref.Operator = op;
            return(oref);
        }
Exemple #30
0
        /// <summary>
        /// Creates a new join of the specified type and the ON set to the specified comparison
        /// </summary>
        /// <param name="jointo"></param>
        /// <param name="joinType"></param>
        /// <param name="comp"></param>
        /// <returns></returns>
        public static DBJoin Join(DBClause jointo, JoinType joinType, DBComparison comp)
        {
            DBJoinRef jref = new DBJoinRef();

            jref.JoinType   = joinType;
            jref.JoinedTo   = jointo;
            jref.Comparison = comp;

            return(jref);
        }