public async Task ExecuteAsync(ScriptFile script, BuildItem.BuildActionType action) { string cmdText; switch (action) { case BuildItem.BuildActionType.Drop: return; case BuildItem.BuildActionType.Alter: cmdText = script.Sql.GetAlterScript(); break; case BuildItem.BuildActionType.Create: case BuildItem.BuildActionType.DropAndCreate: cmdText = script.Sql.GetCreateScript(); break; default: throw new NotSupportedException(string.Format("Unable to execute a script for build action type {0}.", action)); } using (var cmd = _connection.CreateCommand()) { cmd.CommandText = cmdText; cmd.Transaction = _transaction; await cmd.ExecuteNonQueryAsync(); } }
public async Task ExecuteAsync(ScriptFile script, BuildItem.BuildActionType action) { if (action == BuildItem.BuildActionType.Drop || action == BuildItem.BuildActionType.DropAndCreate) { using (var cmd = _connection.CreateCommand()) { cmd.CommandText = string.Format("DROP {0} [{1}].[{2}]", script.ScriptObject.ObjectType.ToString(), script.ScriptObject.SchemaName, script.ScriptObject.ObjectName); cmd.Transaction = _transaction; await cmd.ExecuteNonQueryAsync(); } } }