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); }
protected internal virtual ColumnAssignment VisitColumnAssigment(ColumnAssignment c) { var exp = Visit(c.Expression); if (exp != c.Expression) { return(new ColumnAssignment(c.Column, exp)); } return(c); }
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); }
protected virtual bool CompareAssigment(ColumnAssignment a, ColumnAssignment b) { return(a.Column == b.Column && Compare(a.Expression, b.Expression)); }