using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Repositories; using EMIS.ViewModel.ScoreManage; using System.Linq.Expressions; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.Cultureplan; using EMIS.DataLogic.Common.Cultureplan; namespace EMIS.DataLogic.ScoreManage { public class MisconductDAL { public MisconductRepository MisconductRepository { get; set; } public DictionaryItemRepository DictionaryItemRepository { get; set; } public EducationMissionRepository EducationMissionRepository { get; set; } public EducationMissionClassRepository EducationMissionClassRepository { get; set; } public SchoolyearRepository SchoolyearRepository { get; set; } public StudentRepository StudentRepository { get; set; } public FinalExaminationRepository FinalExaminationRepository { get; set; } public CoursematerialRepository CoursematerialRepository { get; set; } public Lazy CoursematerialDAL { get; set; } public IQueryable GetMisconductViewQueryable(Expression> exp) { var query = (from m in MisconductRepository.GetList(exp) select new MisconductView { MisconductID = m.MisconductID, UserID = m.UserID, LoginID = m.CF_Student.Sys_User.LoginID, Name = m.CF_Student.Sys_User.Name, ClassmajorName = m.CF_Student.CF_Classmajor.Name, CollegeID = m.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID, Year = m.CF_Student.CF_Classmajor.CF_Grademajor.GradeID, StandardID = m.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID, SchoolyearID = m.SchoolyearID, SchoolyearCode = m.CF_Schoolyear.Code, CoursematerialID = m.CoursematerialID, CourseCode = m.EM_Coursematerial.CourseCode, CourseName = m.EM_Coursematerial.CourseName, ExamsCategoryID = m.ExamsCategoryID, ExamsStateID = m.ExamsStateID, Reason = m.Reason, RecordStatus = m.RecordStatus, CreateTime = m.CreateTime }); return query; } public IQueryable GetMisconductCoursematerialViewQueryable(Expression> schoolyearExp, Expression> studentExp) { var coursematerialIDQuery = ( from emc in EducationMissionClassRepository.Entities join em in EducationMissionRepository.Entities on emc.EducationMissionID equals em.EducationMissionID join cm in CoursematerialRepository.Entities on emc.CoursematerialID equals cm.CoursematerialID join sy in SchoolyearRepository.GetList(schoolyearExp) on em.SchoolyearID equals sy.SchoolyearID from esc in emc.EM_EducationSchedulingClass from esccs in esc.CF_Student join s in StudentRepository.GetList(studentExp) on esccs.UserID equals s.UserID group emc by new { emc.CoursematerialID, cm.CourseCode, cm.CourseName } into g select new { CoursematerialID = g.Key.CoursematerialID } ).Concat( from fe in FinalExaminationRepository.Entities join sy in SchoolyearRepository.GetList(schoolyearExp) on fe.SchoolyearID equals sy.SchoolyearID from fes in fe.ER_FinalExaminationStudent join s in StudentRepository.GetList(studentExp) on fes.UserID equals s.UserID group fe by fe.CoursematerialID into g select new { CoursematerialID = g.Key } ); var query = (from cid in coursematerialIDQuery.Distinct() join cmv in CoursematerialDAL.Value.GetCoursematerialViewQueryable(x => true) on cid.CoursematerialID equals cmv.CoursematerialID select cmv); return query; } } }