示例#1
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);
        }
示例#2
0
        protected internal virtual ColumnAssignment VisitColumnAssigment(ColumnAssignment c)
        {
            var exp = Visit(c.Expression);

            if (exp != c.Expression)
            {
                return(new ColumnAssignment(c.Column, exp));
            }
            return(c);
        }
示例#3
0
 protected internal override Expression VisitInsertSelect(InsertSelectExpression insertSelect)
 {
     sb.Append("INSERT INTO ");
     sb.Append(insertSelect.Name.ToString());
     sb.Append("(");
     for (int i = 0, n = insertSelect.Assigments.Count; i < n; i++)
     {
         ColumnAssignment assignment = insertSelect.Assigments[i];
         if (i > 0)
         {
             sb.Append(", ");
             if (i % 4 == 0)
             {
                 this.AppendNewLine(Indentation.Same);
             }
         }
         sb.Append(assignment.Column.SqlEscape());
     }
     sb.Append(")");
     this.AppendNewLine(Indentation.Same);
     sb.Append("SELECT ");
     for (int i = 0, n = insertSelect.Assigments.Count; i < n; i++)
     {
         ColumnAssignment assignment = insertSelect.Assigments[i];
         if (i > 0)
         {
             sb.Append(", ");
             if (i % 4 == 0)
             {
                 this.AppendNewLine(Indentation.Same);
             }
         }
         this.Visit(assignment.Expression);
     }
     sb.Append(" FROM ");
     VisitSource(insertSelect.Source);
     return(insertSelect);
 }
示例#4
0
 protected virtual bool CompareAssigment(ColumnAssignment a, ColumnAssignment b)
 {
     return(a.Column == b.Column && Compare(a.Expression, b.Expression));
 }