/// <summary> /// Inserts a new record into the dbo.ContactoEmergencia table. /// SQL+ Routine: dbo.ContactoEmergenciaInsert - Authored by Ivo Strficek /// </summary> public ContactoEmergenciaInsertOutput ContactoEmergenciaInsert(IContactoEmergenciaInsertInput input) { if (!input.IsValid()) { throw new ArgumentException("ContactoEmergenciaInsertInput fails validation - use the ContactoEmergenciaInsertInput.IsValid() method prior to passing the input argument to the ContactoEmergenciaInsert method.", "input"); } ContactoEmergenciaInsertOutput output = new ContactoEmergenciaInsertOutput(); if (sqlConnection != null) { using (SqlCommand cmd = GetContactoEmergenciaInsertCommand(sqlConnection, input)) { cmd.Transaction = sqlTransaction; ContactoEmergenciaInsertCommand(cmd, output); } return(output); } for (int idx = 0; idx <= retryOptions.RetryIntervals.Count; idx++) { if (idx > 0) { System.Threading.Thread.Sleep(retryOptions.RetryIntervals[idx - 1]); } try { using (SqlConnection cnn = new SqlConnection(connectionString)) using (SqlCommand cmd = GetContactoEmergenciaInsertCommand(cnn, input)) { cnn.Open(); ContactoEmergenciaInsertCommand(cmd, output); cnn.Close(); } break; } catch (SqlException sqlException) { bool throwException = true; if (retryOptions.TransientErrorNumbers.Contains(sqlException.Number)) { throwException = (idx == retryOptions.RetryIntervals.Count); if (retryOptions.Logger != null) { retryOptions.Logger.Log(sqlException); } } if (throwException) { throw; } } } return(output); }
private void SetContactoEmergenciaInsertCommandOutputs(SqlCommand cmd, ContactoEmergenciaInsertOutput output) { if (cmd.Parameters[0].Value != DBNull.Value) { output.IdContactoEmergencia = (int?)cmd.Parameters[0].Value; } if (cmd.Parameters[5].Value != DBNull.Value) { output.ReturnValue = (ContactoEmergenciaInsertOutput.Returns)cmd.Parameters[5].Value; } }
private void ContactoEmergenciaInsertCommand(SqlCommand cmd, ContactoEmergenciaInsertOutput output) { cmd.ExecuteNonQuery(); SetContactoEmergenciaInsertCommandOutputs(cmd, output); }