using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Repositories; using EMIS.ViewModel.MinorManage.MinorPlanManage; using EMIS.Entities; using System.Linq.Expressions; using EMIS.ViewModel.Students; namespace EMIS.DataLogic.MinorManage.MinorPlanManage { public class MinorSpecialtyDAL { public GrademinorRepository GrademinorRepository { get; set; } public UserRepository UserRepository { get; set; } public CollegeRepository CollegeRepository { get; set; } public SchoolyearRepository SchoolyearRepository { get; set; } public StudentMinorRegistRepository studentMinorRegistRepository { get; set; } public StudentRepository studentRepository { get; set; } public ClassmajorRepository classmajorRepository { get; set; } public GrademajorRepository grademajorRepository { get; set; } public FacultymajorRepository facultymajorRepository { get; set; } public CollegeRepository collegeRepository { get; set; } public IQueryable GetMinorSpecialtyViewQueryable(Expression> exp) { var query = from Grademinor in GrademinorRepository.GetList(exp) join User in UserRepository.Entities on Grademinor.CreateUserID equals User.UserID into user from u in user.DefaultIfEmpty() join College in CollegeRepository.Entities on Grademinor.CollegeID equals College.CollegeID join schoolYear in SchoolyearRepository.Entities on Grademinor.SchoolyearID equals schoolYear.SchoolyearID select new MinorSpecialtyView { GrademinorID=Grademinor.GrademinorID, GradeMinorApplicationID = Grademinor.GrademinorApplicationID, YearID = Grademinor.YearID, SchoolyearID = Grademinor.SchoolyearID, SchoolyearCode=schoolYear.Code, StandardID = Grademinor.StandardID, CollegeID = Grademinor.CollegeID, CollegeName = College.Name, CollegeNo = College.No, StudentLimit = Grademinor.StudentLimit, OpenStatus = Grademinor.RecordStatus, CreateUserID = Grademinor.CreateUserID, CreateTime = Grademinor.CreateTime, CreateUserName = u.Name, StudentCount = Grademinor.EM_StudentMinorRegist.GroupBy(x => x.UserID).Count(), }; return query; } public IQueryable GetStudentsQueryable(Expression> exp) { var query = from stumrr in studentMinorRegistRepository.GetList(exp) group stumrr by stumrr.UserID into gstu join user in UserRepository.Entities on gstu.Key equals user.UserID join stu in studentRepository.Entities on gstu.Key equals stu.UserID join cla in classmajorRepository.Entities on stu.ClassmajorID equals cla.ClassmajorID join gra in grademajorRepository.Entities on cla.GrademajorID equals gra.GrademajorID join fac in facultymajorRepository.Entities on gra.FacultymajorID equals fac.FacultymajorID join col in collegeRepository.Entities on fac.CollegeID equals col.CollegeID select new StudentsView { CollegeID = col.CollegeID, CollegeName = col.Name, CollegeCode = col.No, GradeMajorID = gra.GrademajorID, GradeMajorCode = gra.Code, GradeMajorName = gra.Name, ClassMajorID = cla.GrademajorID, ClassMajorName = cla.Name, ClassMajorCode = cla.No, LoginID = user.LoginID, UserName = user.Name, UserID = user.UserID, }; return query; } } }