protected virtual bool CompareUpdate(UpdateExpression a, UpdateExpression b)
 {
     return(a.Table == b.Table &&
            CompareList(a.Assigments, b.Assigments, CompareAssigment) &&
            Compare(a.Source, b.Source) &&
            Compare(a.Where, b.Where));
 }
        protected internal override Expression VisitUpdate(UpdateExpression update)
        {
            sb.Append("UPDATE ");
            sb.Append(update.Name.ToString());
            sb.Append(" SET");
            this.AppendNewLine(Indentation.Inner);

            for (int i = 0, n = update.Assigments.Count; i < n; i++)
            {
                ColumnAssignment assignment = update.Assigments[i];
                if (i > 0)
                {
                    sb.Append(",");
                    this.AppendNewLine(Indentation.Same);
                }
                sb.Append(assignment.Column.SqlEscape());
                sb.Append(" = ");
                this.Visit(assignment.Expression);
            }
            this.AppendNewLine(Indentation.Outer);
            sb.Append("FROM ");
            VisitSource(update.Source);
            if (update.Where != null)
            {
                this.AppendNewLine(Indentation.Same);
                sb.Append("WHERE ");
                Visit(update.Where);
            }
            return(update);
        }
Exemple #3
0
 protected virtual bool CompareUpdate(UpdateExpression a, UpdateExpression b)
 {
     return(a.Table == b.Table &&
            a.UseHistoryTable == b.UseHistoryTable &&
            CompareList(a.Assigments, b.Assigments, CompareAssigment) &&
            Compare(a.Source, b.Source) &&
            Compare(a.Where, b.Where) &&
            a.ReturnRowCount == b.ReturnRowCount);
 }
Exemple #4
0
        protected internal override Expression VisitUpdate(UpdateExpression update)
        {
            if (update.ReturnRowCount == false)
            {
                return(update);
            }

            return(new UpdateExpression(update.Table, update.UseHistoryTable, update.Source, update.Where, update.Assigments, returnRowCount: false));
        }
Exemple #5
0
        protected internal override Expression VisitUpdate(UpdateExpression update)
        {
            var where = Visit(update.Where);
            var assigments = Visit(update.Assigments, VisitColumnAssigment);
            var source     = Visit(update.Source);

            if (source != update.Source || where != update.Where || assigments != update.Assigments)
            {
                return(new UpdateExpression(update.Table, update.UseHistoryTable, (SourceWithAliasExpression)source, where, assigments));
            }
            return(update);
        }
        protected internal override Expression VisitUpdate(UpdateExpression update)
        {
            var source = Visit(update.Source);

            var where = Visit(update.Where);
            var assigments = Visit(update.Assigments, c =>
            {
                var exp = MakeSqlValue(Visit(c.Expression));
                if (exp != c.Expression)
                {
                    return(new ColumnAssignment(c.Column, exp));
                }
                return(c);
            });

            if (source != update.Source || where != update.Where || assigments != update.Assigments)
            {
                return(new UpdateExpression(update.Table, update.UseHistoryTable, (SelectExpression)source, where, assigments));
            }
            return(update);
        }
Exemple #7
0
        protected internal override Expression VisitUpdate(UpdateExpression update)
        {
            var coll = GetColumnCollector(update.Source.KnownAliases);

            coll.Visit(update.Where);
            foreach (var ca in update.Assigments)
            {
                coll.Visit(ca.Expression);
            }

            var source = Visit(update.Source);

            var where = Visit(update.Where);
            var assigments = Visit(update.Assigments, VisitColumnAssigment);

            if (source != update.Source || where != update.Where || assigments != update.Assigments)
            {
                return(new UpdateExpression(update.Table, update.UseHistoryTable, (SourceWithAliasExpression)source, where, assigments));
            }

            return(update);
        }