private List <PredictionComponent> GetPredictionComponents(int prediction_id) { using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(PredictionQueries.GetPredictionComponents(prediction_id), connection); connection.Open(); try { using (SqlDataReader reader = command.ExecuteReader()) { CompetitionRepository compRepo = new CompetitionRepository(new CompetitionRepositorySQLContext()); List <PredictionComponent> list = new List <PredictionComponent>(); while (reader.Read()) { PredictionComponent pc = new PredictionComponent(); pc.ID = (int)reader["ID"]; pc.Driver_id = (int)reader["driver_id"]; pc.Driver = compRepo.GetDriver(pc.Driver_id); pc.Position = (int)reader["position"]; pc.Checked = (bool)reader["checked"]; if (pc.Checked) { pc.Correct = (bool)reader["correct"]; } list.Add(pc); } return(list); } } catch (SqlException e) { throw e; } } }