示例#1
0
        SelectQuery(SelectQuery clone, Dictionary <ICloneableElement, ICloneableElement> objectTree, Predicate <ICloneableElement> doClone)
        {
            objectTree.Add(clone, this);
            objectTree.Add(clone.All, All);

            SourceID = Interlocked.Increment(ref SourceIDCounter);

            ICloneableElement parentClone;

            if (clone.ParentSelect != null)
            {
                ParentSelect = objectTree.TryGetValue(clone.ParentSelect, out parentClone) ? (SelectQuery)parentClone : clone.ParentSelect;
            }

            _queryType = clone._queryType;

            if (IsInsert)
            {
                _insert = (SqlInsertClause)clone._insert.Clone(objectTree, doClone);
            }
            if (IsUpdate)
            {
                _update = (SqlUpdateClause)clone._update.Clone(objectTree, doClone);
            }
            if (IsDelete)
            {
                _delete = (SqlDeleteClause)clone._delete.Clone(objectTree, doClone);
            }

            Select   = new SqlSelectClause(this, clone.Select, objectTree, doClone);
            _from    = new SqlFromClause(this, clone._from, objectTree, doClone);
            _where   = new SqlWhereClause(this, clone._where, objectTree, doClone);
            _groupBy = new SqlGroupByClause(this, clone._groupBy, objectTree, doClone);
            _having  = new SqlWhereClause(this, clone._having, objectTree, doClone);
            _orderBy = new SqlOrderByClause(this, clone._orderBy, objectTree, doClone);

            Parameters.AddRange(clone.Parameters.Select(p => (SqlParameter)p.Clone(objectTree, doClone)));
            IsParameterDependent = clone.IsParameterDependent;

            new QueryVisitor().Visit(this, expr =>
            {
                var sb = expr as SelectQuery;

                if (sb != null && sb.ParentSelect == clone)
                {
                    sb.ParentSelect = this;
                }
            });
        }
示例#2
0
        public ICloneableElement Clone(Dictionary <ICloneableElement, ICloneableElement> objectTree, Predicate <ICloneableElement> doClone)
        {
            if (!doClone(this))
            {
                return(this);
            }

            var clone = new SqlDeleteClause();

            if (Table != null)
            {
                clone.Table = (SqlTable)Table.Clone(objectTree, doClone);
            }

            objectTree.Add(this, clone);

            return(clone);
        }
示例#3
0
        internal void Init(
            SqlInsertClause insert,
            SqlUpdateClause update,
            SqlDeleteClause delete,
            SqlSelectClause select,
            SqlFromClause from,
            SqlWhereClause where,
            SqlGroupByClause groupBy,
            SqlWhereClause having,
            SqlOrderByClause orderBy,
            List <SqlUnion> unions,
            SelectQuery parentSelect,
            bool parameterDependent,
            List <SqlParameter> parameters)
        {
            _insert              = insert;
            _update              = update;
            _delete              = delete;
            Select               = select;
            _from                = from;
            _where               = where;
            _groupBy             = groupBy;
            _having              = having;
            _orderBy             = orderBy;
            _unions              = unions;
            ParentSelect         = parentSelect;
            IsParameterDependent = parameterDependent;

            Parameters.AddRange(parameters);

            foreach (var col in select.Columns)
            {
                col.Parent = this;
            }

            Select.SetSqlQuery(this);
            _from.SetSqlQuery(this);
            _where.SetSqlQuery(this);
            _groupBy.SetSqlQuery(this);
            _having.SetSqlQuery(this);
            _orderBy.SetSqlQuery(this);
        }
示例#4
0
 public void ClearDelete()
 {
     _delete = null;
 }