using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.ViewModel; using EMIS.ViewModel.ExaminationManage; using System.Linq.Expressions; using EMIS.Entities; namespace EMIS.ExtensionLogic.DataLogic.ExaminationManage { public class ExaminationPLanDAL : EMIS.DataLogic.ExaminationManage.ExaminationPlanDAL { public override IQueryable GetExaminationPlanByEducationMission( Expression> educationMissionExpression, Expression> emcExp) { var missionClassQuery = ( from emc in EducationMissionClassRepository.GetList(emcExp) join cm in CoursematerialRepository.Entities on emc.CoursematerialID equals cm.CoursematerialID join ems in ExaminationModeSettingRepository.GetList(x => x.IsGeneratePlan == false) on emc.ExaminationModeID equals ems.ExaminationModeID into dems from eems in dems.DefaultIfEmpty() from esc in emc.EM_EducationSchedulingClass from s in esc.CF_Student where emc.RecordStatus != (int)EM_EducationMissionClassStatus.NotSubmitted && eems.ExaminationModeSettingID == null && emc.HandleModeID == (int)CF_HandleMode.RequiredCourse group emc by new { emc.EducationMissionID, emc.CoursematerialID, cm.CourseName, emc.ExaminationModeID, s.ClassmajorID, s.CF_Classmajor.Name } into g select g.Key ); var q = (from em in EducationMissionRepository.GetList(educationMissionExpression) join c in missionClassQuery on em.EducationMissionID equals c.EducationMissionID from eep in ExaminationPlanRepository.Entities.Where(x => x.EducationMissionID == em.EducationMissionID && x.ClassmajorID == c.ClassmajorID).DefaultIfEmpty() where eep.ExaminationPlanID == null select new ExaminationPlanView { SchoolyearID = em.SchoolyearID, CollegeID = em.CollegeID, CoursematerialID = c.CoursematerialID, ExaminationModeID = c.ExaminationModeID, ExaminationStyleID = (int)EX_ExaminationStyle.CloseBook, EducationMissionID = em.EducationMissionID, ClassmajorID = c.ClassmajorID, ClassName = c.Name, ExaminationDate = null, StartTime = null, EndTime = null, Students = (from esc in educationSchedulingClassRepository.Entities from emc in EducationMissionClassRepository.Entities.Where(x => x.EducationMissionClassID == esc.EducationMissionClassID) from s in esc.CF_Student where emc.EducationMissionID == em.EducationMissionID && s.ClassmajorID == c.ClassmajorID group s by s.UserID into g select g.FirstOrDefault()) }); return q; } } }