protected List <T> ExecuteListCommand <T>(SqlProcedureCommand cmd, ProcessDataRecordFunction <T> processRecordFunction) { var list = new List <T>(); try { using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { list.Add(processRecordFunction(reader)); } } } catch (SqlException e) { string message; try { message = DataDiagnostics.FormatCommandExceptionMessage(cmd.Command, 0); } catch (System.Exception ex) { message = ex.Message; } throw ReportAndTranslateException(e, message); } return(list); }
protected T[] ExecuteArrayCommand <T>(SqlProcedureCommand cmd, ProcessDataRecordFunction <T> processRecordFunction) { return(ExecuteListCommand(cmd, processRecordFunction).ToArray()); }
protected T[] ExecuteArrayCommand <T>(string storedProcedureName, ProcessDataRecordFunction <T> processRecordFunction) { return(ExecuteListCommand(storedProcedureName, processRecordFunction).ToArray()); }