Beispiel #1
0
        internal override object Clone(SqlNodeCloneContext context)
        {
            if (context.NodeMapping.ContainsKey(this))
            {
                return(context.NodeMapping[this]);
            }

            SqlInsert clone = new SqlInsert();

            if (Into != null)
            {
                clone.Into = (SqlTableRef)Into.Clone(context);
            }
            if (from != null)
            {
                clone.From = (SqlSelect)from.Clone(context);
            }
            foreach (KeyValuePair <SqlColumn, SqlExpression> p in values)
            {
                clone.Values[(SqlTableColumn)p.Key.Clone(context)] =
                    p.Value.IsNullReference() ? null : (SqlExpression)p.Value.Clone(context);
            }

            if (Hints.Count > 0)
            {
                foreach (SqlHint hint in Hints)
                {
                    clone.Hints.Add((SqlHint)hint.Clone(context));
                }
            }

            context.NodeMapping[this] = clone;
            return(clone);
        }
Beispiel #2
0
        public ICloneableElement Clone(Dictionary <ICloneableElement, ICloneableElement> objectTree, Predicate <ICloneableElement> doClone)
        {
            if (!doClone(this))
            {
                return(this);
            }

            var clone = new SqlInsertClause {
                WithIdentity = WithIdentity
            };

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

            foreach (var item in Items)
            {
                clone.Items.Add((SqlSetExpression)item.Clone(objectTree, doClone));
            }

            objectTree.Add(this, clone);

            return(clone);
        }
Beispiel #3
0
        /// <summary>
        /// Accepts the specified <paramref name="visitor"/> and dispatches calls to the specific visitor
        /// methods for this object.
        /// </summary>
        /// <param name="visitor">
        /// The <see cref="ISqlVisitor" /> to visit this object with.
        /// </param>
        public override void Accept(ISqlVisitor visitor)
        {
            base.Accept(visitor);

            Into?.Accept(visitor);
            Columns?.Accept(visitor);
            Values.Accept(visitor);
        }
Beispiel #4
0
 public override void AcceptChildren(WSqlFragmentVisitor visitor)
 {
     if (Into != null)
     {
         Into.Accept(visitor);
     }
     if (QueryExpr != null)
     {
         QueryExpr.Accept(visitor);
     }
     base.AcceptChildren(visitor);
 }
Beispiel #5
0
        IQueryExpression ISqlExpressionWalkable.Walk(bool skipColumns, Func <IQueryExpression, IQueryExpression> func)
        {
            if (Into != null)
            {
                Into.Walk(skipColumns, func);
            }

            foreach (var t in Items)
            {
                t.Walk(skipColumns, func);
            }

            return(null);
        }
        public TableSelectExpression Prepare(IExpressionPreparer preparer)
        {
            var selectExp = new TableSelectExpression {
                GroupMax          = GroupMax,
                Distinct          = Distinct,
                CompositeFunction = CompositeFunction,
                IsCompositeAll    = IsCompositeAll
            };

            foreach (var column in Columns)
            {
                selectExp.Columns.Add(column.Prepare(preparer));
            }

            if (From != null)
            {
                selectExp.From = From.Prepare(preparer);
            }

            if (Into != null)
            {
                selectExp.Into = Into.Prepare(preparer);
            }

            if (whereClause != null)
            {
                selectExp.Where = whereClause.Prepare(preparer);
            }

            foreach (var column in GroupBy)
            {
                selectExp.GroupBy.Add(column.Prepare(preparer));
            }

            if (Having != null)
            {
                selectExp.Having = Having.Prepare(preparer);
            }

            if (NextComposite != null)
            {
                selectExp.NextComposite = NextComposite.Prepare(preparer);
            }

            return(selectExp);
        }
Beispiel #7
0
        public override StringBuilder ToString(StringBuilder sb, Dictionary <IQueryElement, IQueryElement> dic)
        {
            sb.Append("VALUES ");

            if (Into != null)
            {
                Into.ToString(sb, dic);
            }

            sb.AppendLine();

            foreach (var e in Items)
            {
                sb.Append("\t");
                e.ToString(sb, dic);
                sb.AppendLine();
            }

            return(sb);
        }
        // Used for Debug only
        public override string ToString()
        {
            var toReturn = "<div>" +
                           Id + " : " +
                           Name + "<br/>" +
                           "Consumable? " + Consumed +
                           Gold;

            if (Into != null && Into.Any())
            {
                toReturn += "Builds into " + Into.Count() + " items. <br />";
            }
            if (From != null && From.Any())
            {
                toReturn += "Builds from " + From.Count() + " items.";
            }

            toReturn += "</div>";

            return(toReturn);
        }
Beispiel #9
0
        public ICloneableElement Clone(Dictionary <ICloneableElement, ICloneableElement> objectTree,
                                       Predicate <ICloneableElement> doClone)
        {
            if (!doClone(this))
            {
                return(this);
            }

            var clone = new InsertClause {
                WithIdentity = WithIdentity
            };

            if (Into != null)
            {
                clone.Into = (ISqlTable)Into.Clone(objectTree, doClone);
            }

            Items.ForEach(
                node => { clone.Items.AddLast((ISetExpression)node.Value.Clone(objectTree, doClone)); });

            objectTree.Add(this, clone);

            return(clone);
        }