using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.ViewModel.MinorManage.MinorApply; using System.Linq.Expressions; using EMIS.Entities; using EMIS.DataLogic.Repositories; namespace EMIS.DataLogic.MinorManage.MinorApply { public class StudentMinorDAL { public StudentMinorRegistRepository studentMinorRegistRepository { get; set; } public UserRepository userRepository { get; set; } public GrademinorRepository grademinorRepository { get; set; } public CollegeRepository collegeRepository { get; set; } public DictionaryItemRepository dictionaryItemRepository { get; set; } public ClassminorStudentRepository classminorStudentRepository { get; set; } public ClassminorRepository classminorRepository { get; set; } public IQueryable GetStudentMinorViewQueryable(Expression> exp) { var query = from smrr in studentMinorRegistRepository.GetList(exp) join user in userRepository.Entities on smrr.UserID equals user.UserID join gra in grademinorRepository.Entities on smrr.GrademinorID equals gra.GrademinorID join dic in dictionaryItemRepository.GetList(x => x.DictionaryCode == "CF_Standard") on gra.StandardID equals dic.Value join col in collegeRepository.Entities on gra.CollegeID equals col.CollegeID select new StudentMinorView { StudentMinorRegistID = smrr.StudentMinorRegistID, UserID = smrr.UserID, UserName = user.Name, LoginID = user.LoginID, GradeYearID = gra.YearID, CollegeID = gra.CollegeID, CollegeCode = col.No, CollegeName = col.Name, GrademinorID = gra.GrademinorID, GrademinorCode = dic.Code, GrademinorName = dic.Name, RecordStatus = smrr.RecordStatus, }; return query; } public Guid? GetGrademinorIDByUserID(Guid userID) { var query = from csr in classminorStudentRepository.GetList(x => x.UserID == userID) join cr in classminorRepository.Entities on csr.ClassminorID equals cr.ClassminorID select new { GrademinorID = cr.GrademinorID }; if (query.FirstOrDefault() != null) { return query.FirstOrDefault().GrademinorID; } return null; } } }