public override DbExpression Visit(DbUpdateExpression exp) { this.SqlBuilder.Append("UPDATE "); this.AppendTable(exp.Table); this.SqlBuilder.Append(" SET "); bool first = true; foreach (var item in exp.UpdateColumns) { if (first) { first = false; } else { this.SqlBuilder.Append(","); } this.QuoteName(item.Key.Name); this.SqlBuilder.Append("="); DbExpression valExp = DbExpressionExtension.StripInvalidConvert(item.Value); AmendDbInfo(item.Key, valExp); DbValueExpressionTransformer.Transform(valExp).Accept(this); } this.BuildWhereState(exp.Condition); return(exp); }
public override DbExpression Visit(DbInsertExpression exp) { string separator = ""; this.SqlBuilder.Append("INSERT INTO "); this.AppendTable(exp.Table); this.SqlBuilder.Append("("); separator = ""; foreach (var item in exp.InsertColumns) { this.SqlBuilder.Append(separator); this.QuoteName(item.Key.Name); separator = ","; } this.SqlBuilder.Append(")"); this.SqlBuilder.Append(" VALUES("); separator = ""; foreach (var item in exp.InsertColumns) { this.SqlBuilder.Append(separator); DbExpression valExp = DbExpressionExtension.StripInvalidConvert(item.Value); AmendDbInfo(item.Key, valExp); DbValueExpressionTransformer.Transform(valExp).Accept(this); separator = ","; } this.SqlBuilder.Append(")"); if (exp.Returns.Count > 0) { this.SqlBuilder.Append(" returning "); separator = ""; foreach (DbColumn returnColumn in exp.Returns) { this.SqlBuilder.Append(separator); this.QuoteName(returnColumn.Name); separator = ","; } } return(exp); }
internal void AppendColumnSegment(DbColumnSegment seg) { DbValueExpressionTransformer.Transform(seg.Body).Accept(this); this.SqlBuilder.Append(" AS "); this.QuoteName(seg.Alias); }