Skip to content

Instantly share code, notes, and snippets.

@anlai
Created May 29, 2013 17:58
Show Gist options
  • Save anlai/5672313 to your computer and use it in GitHub Desktop.
Save anlai/5672313 to your computer and use it in GitHub Desktop.
model.SectionDetails = (from section in repositoryFactory.SectionRepository.Queryable
let sequence = section.Course.CrossListedCourse == null ? section.Sequence : string.Format("{0} ({1} {2})", section.Sequence, section.Course.Subject, section.Course.CourseNumb)
let students = (decimal)section.ClassTimes.SelectMany(a => a.Students).Select(a => a.LoginId).Distinct().Count()
let responses = (decimal)section.ClassTimes.SelectMany(a => a.ClassTimeEvaluations).SelectMany(a => a.EvaluationResponses).Count()
let evals = section.ClassTimes.SelectMany(a => a.ClassTimeEvaluations).Count()
let instructors = section.ClassTimes.SelectMany(a => a.Instructors)
where section.Course == course || section.Course.CrossListedCourse == course
select new SectionDetail() { SectionId = section.Id, Sequence = sequence,
Students = (int)students, ResponseRate = ((responses)/(students*evals))*100,
InstructorList = instructors}
).ToList();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment