private string Enrollments() { var enrollments = db.Enrollments .Include(e => e.User) .Include(e => e.IMSClass) .Include(e => e.School); var sb = new StringBuilder(); using (var csv = new CsvWriter(new StringWriter(sb))) { Enrollment.CsvHeader(csv); foreach (var enrollment in enrollments) { enrollment.AsCsvRow(csv); } return(sb.ToString()); } }