public List<StudentExport> exportList(List<Student> list) { BandStudentDBEntities db = new BandStudentDBEntities(); var export = (from student in list select new StudentExport { StudentFirstName = student.StudentFirstName, StudentLastName = student.StudentLastName, StudentAddress = student.StudentAddress, StudentCity = student.StudentCity, StudentState = student.StudentState, StudentZipCode = student.StudentZipCode, StudentPhone = student.StudentPhone, PerformanceMedium = student.PerformanceMedium, GraduationYear = student.GraduationYear, EmailAddress = student.EmailAddress, ApplicationDate = student.ApplicationDateSubString }).ToList(); return export; }
public void GetStudents(string FilterType, string SearchString, string startDate, string endDate, ref List<Student> filterContent) { BandStudentDBEntities db = new BandStudentDBEntities(); if (FilterType != null || FilterType != string.Empty || SearchString != null) { if (FilterType == "ContactedDate") { if (!(startDate == string.Empty) && !(endDate == string.Empty)) { var dsd = Convert.ToDateTime(startDate); var ded = Convert.ToDateTime(endDate).AddDays(1); var x = (from a in db.Students join a2 in db.StudentContacts on a.StudentID equals a2.StudentId where a2.ContactedDate >= dsd && a2.ContactedDate < ded select a).ToList(); filterContent = x.GroupBy(p => p.StudentID).Select(g => g.FirstOrDefault()).ToList(); // db.Students // .Join(db.StudentContacts, // sid => sid.StudentID, // cid => cid.StudentId, // (astudent, contact) => new // { // astudent, // contact.ContactedDate // }) // .Where(s => s.ContactedDate >= dsd && s.ContactedDate <= ded) // .Select(s => s); //StudentListConvert(x, ref filterContent); } } if (FilterType == "InterestArea") { var x = (from a in db.Students join a2 in db.InterestAreatoStudents on a.StudentID equals a2.StudentID join a3 in db.InterestAreas on a2.InterestAreaID equals a3.InterestAreaID where a3.InterestAreaName.Contains(SearchString) select a).ToList(); filterContent = x.GroupBy(p => p.StudentID).Select(g => g.FirstOrDefault()).ToList(); } if (FilterType == "ApplicationDate") { var dsd = Convert.ToDateTime(startDate); var ded = Convert.ToDateTime(endDate).AddDays(1); filterContent = (from a in db.Students where a.ApplicationDate >= dsd && a.ApplicationDate < ded select a).ToList(); } else { try { filterContent = db.Students .Where(FilterType + ".Contains(@0)", SearchString) .Select(s => s).ToList(); } catch (Exception) { } } } }