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));
 }
예제 #2
0
        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);
        }
예제 #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);
 }
예제 #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));
        }
예제 #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);
        }
예제 #6
0
        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);
        }
예제 #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);
        }