// GET: Surveys/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Survey survey = db.Surveys.Find(id); if (survey == null) { return(HttpNotFound()); } ViewBag.NumResponse = db.SurveyResponses.Where(sr => sr.SurveyID == survey.SurveyID).Count(); var questions = survey.SurveyQuestions; var surveyResponse = from sr in db.SurveyResponses where sr.SurveyID == survey.SurveyID select sr; //select new ResponseAndAnswer { response = sr, answers = SurveyAnswer.FromDB(sr.SurveyMAAs, sr.SurveyMCAs, sr.SurveySAAs)}; var s = surveyResponse.ToList().Select(sr => { return(new ResponseAndAnswer(sr, SurveyAnswer.FromDB(sr.SurveyMAAs, sr.SurveyMCAs, sr.SurveySAAs))); }); ViewBag.Questions = questions; ViewBag.SurveyResponse = s.ToList(); return(View(survey)); }