protected override void PrepareCommand(Row row, SqlCommand command) { var fields = _entity.OutputFields(); var writer = new FieldSqlWriter(fields).AddDeleted(_entity); var sets = writer.Alias(_connection.L, _connection.R).SetParam().Write(", ", false); command.CommandText = string.Format(@" UPDATE [{0}] SET {1}, TflBatchId = @TflBatchId WHERE TflKey = @TflKey; ", _entity.OutputName(), sets); foreach (var field in fields) { AddParameter(command, field.Identifier, row[field.Alias]); } if (_entity.Delete) { AddParameter(command, "TflDeleted", false); } AddParameter(command, "TflKey", row["TflKey"]); AddParameter(command, "TflBatchId", _entity.TflBatchId); Logger.EntityDebug(_entity.Alias, command.CommandText); }
public DapperBulkUpdateOperation(AbstractConnection connection, Entity entity) { _connection = connection; _tflBatchId = entity.TflBatchId; _fields = entity.OutputFields(); var writer = new FieldSqlWriter(_fields); var sets = writer.Alias(_connection.L, _connection.R).SetParam().Write(", ", false); _sql = string.Format(@"UPDATE [{0}] SET {1}, TflBatchId = @TflBatchId WHERE TflKey = @TflKey;", entity.OutputName(), sets); }