/// <summary>
        /// Selects single row from dbo.ContactoEmergencia table by identity column.
        /// SQL+ Routine: dbo.ContactoEmergenciaByPacienteId - Authored by IvoStrficek
        /// </summary>
        public ContactoEmergenciaByPacienteIdOutput ContactoEmergenciaByPacienteId(IContactoEmergenciaByPacienteIdInput input)
        {
            if (!input.IsValid())
            {
                throw new ArgumentException("ContactoEmergenciaByPacienteIdInput fails validation - use the ContactoEmergenciaByPacienteIdInput.IsValid() method prior to passing the input argument to the ContactoEmergenciaByPacienteId method.", "input");
            }

            ContactoEmergenciaByPacienteIdOutput output = new ContactoEmergenciaByPacienteIdOutput();

            if (sqlConnection != null)
            {
                using (SqlCommand cmd = GetContactoEmergenciaByPacienteIdCommand(sqlConnection, input))
                {
                    cmd.Transaction = sqlTransaction;
                    ContactoEmergenciaByPacienteIdCommand(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 = GetContactoEmergenciaByPacienteIdCommand(cnn, input))
                        {
                            cnn.Open();
                            ContactoEmergenciaByPacienteIdCommand(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);
        }
        /// <summary>
        /// Builds the command object for ContactoEmergenciaByPacienteId method.
        /// </summary>
        /// <param name="cnn">The connection that will execute the procedure.</param>
        /// <param name="input">ContactoEmergenciaByPacienteIdInput instance for loading parameter values.</param>
        /// <returns>SqlCommand ready for execution.</returns>
        private SqlCommand GetContactoEmergenciaByPacienteIdCommand(SqlConnection cnn, IContactoEmergenciaByPacienteIdInput input)
        {
            SqlCommand result = new SqlCommand()
            {
                CommandType = CommandType.StoredProcedure,
                CommandText = "dbo.ContactoEmergenciaByPacienteId",
                Connection  = cnn
            };

            result.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IdPaciente",
                Direction     = ParameterDirection.Input,
                SqlDbType     = SqlDbType.Int,
                Scale         = 0,
                Precision     = 10,
                Value         = input.IdPaciente
            });

            result.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@ReturnValue",
                Direction     = ParameterDirection.ReturnValue,
                SqlDbType     = SqlDbType.Int,
                Scale         = 0,
                Precision     = 10,
                Value         = DBNull.Value
            });

            return(result);
        }