private void SetFeedbackByIdCommandOutputs(SqlCommand cmd, FeedbackByIdOutput output) { if (cmd.Parameters[1].Value != DBNull.Value) { output.ReturnValue = (FeedbackByIdOutput.Returns)cmd.Parameters[1].Value; } }
/// <summary> /// Selects single row from dbo.Feedback table by identity column. /// SQL+ Routine: dbo.FeedbackById - Authored by Alan Hyneman /// </summary> public FeedbackByIdOutput FeedbackById(IFeedbackByIdInput input, bool bypassValidation = false) { if (!bypassValidation) { if (!input.IsValid()) { throw new ArgumentException("FeedbackByIdInput fails validation - use the FeedbackByIdInput.IsValid() method prior to passing the input argument to the FeedbackById method.", "input"); } } FeedbackByIdOutput output = new FeedbackByIdOutput(); if (sqlConnection != null) { using (SqlCommand cmd = GetFeedbackByIdCommand(sqlConnection, input)) { cmd.Transaction = sqlTransaction; FeedbackByIdCommand(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 = GetFeedbackByIdCommand(cnn, input)) { cnn.Open(); FeedbackByIdCommand(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 FeedbackByIdCommand(SqlCommand cmd, FeedbackByIdOutput output) { using (SqlDataReader rdr = cmd.ExecuteReader()) { if (rdr.Read()) { output.ResultData = GetFeedbackByIdResultFromReader(rdr); } rdr.Close(); } SetFeedbackByIdCommandOutputs(cmd, output); }