using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Repositories; using EMIS.ViewModel.MinorGraduation.MinorGraduationSetting; using System.Linq.Expressions; using EMIS.Entities; namespace EMIS.DataLogic.MinorGraduation.MinorGraduationSetting { public class MinorGraduationStandardDAL { public MinorGraduationStandardRepository minorGraduationStandardRepository { get; set; } public CollegeRepository collegeRepository { get; set; } public GrademinorRepository grademinorRepository { get; set; } public MinorPlanRepository minorPlanRepository { get; set; } public ClassminorStudentRepository classminorStudentRepository { get; set; } public ClassminorRepository classminorRepository { get; set; } public IQueryable GetMinorGraduationStandardView(Expression> exp) { var query = from mgsr in minorGraduationStandardRepository.GetList(exp) join col in collegeRepository.Entities on mgsr.CollegeID equals col.CollegeID //join gmr in grademinorRepository.Entities //on new { mgsr.CollegeID, mgsr.YearID, mgsr.StandardID } equals new { gmr.CollegeID, gmr.YearID, gmr.StandardID } //join mpr in minorPlanRepository.Entities //on gmr.GrademinorID equals mpr.GrademinorID //group mpr by mpr.GrademinorID //into gmpr select new MinorGraduationStandardView { MinorGraduationStandardID = mgsr.MinorGraduationStandardID, CollegeID = col.CollegeID, CollegeNo = col.No, CollegeName = col.Name, YearID = mgsr.YearID, StandardID = mgsr.StandardID, GraduationCredit = mgsr.GraduationCredit, }; return query; } public IQueryable GetMinorGraduationStandardViewByUserID(Guid? userID) { var query = from clastu in classminorStudentRepository.GetList(x => x.UserID == userID) join cla in classminorRepository.Entities on clastu.ClassminorID equals cla.ClassminorID join gra in grademinorRepository.Entities on cla.GrademinorID equals gra.GrademinorID join mgsr in minorGraduationStandardRepository.Entities on new { gra.CollegeID, gra.YearID, gra.StandardID } equals new { mgsr.CollegeID, mgsr.YearID, mgsr.StandardID } join col in collegeRepository.Entities on mgsr.CollegeID equals col.CollegeID select new MinorGraduationStandardView { MinorGraduationStandardID = mgsr.MinorGraduationStandardID, CollegeID = col.CollegeID, CollegeNo = col.No, CollegeName = col.Name, YearID = mgsr.YearID, StandardID = mgsr.StandardID, GraduationCredit = mgsr.GraduationCredit, }; return query; } } }