using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Repositories; using EMIS.ViewModel.StudentManage.StudentStatistics; using System.Linq.Expressions; using EMIS.Entities; using EMIS.ViewModel; namespace EMIS.DataLogic.StudentManage.StudentStatistics { public class InSchoolSettingDAL { public InSchoolSettingRepository InSchoolSettingRepository { get; set; } public DictionaryItemRepository DictionaryItemRepository { get; set; } public UserRepository UserRepository { get; set; } /// /// 查询对应的在校状态设定信息View(对应的字典表信息左连设定表) /// /// /// /// public IQueryable GetInSchoolSettingViewQueryable(Expression> expDictionaryItem, Expression> expInSchoolSetting) { var query = from dicit in DictionaryItemRepository.GetList(expDictionaryItem) join set in InSchoolSettingRepository.GetList(expInSchoolSetting) on dicit.Value equals set.InSchoolStatusID into tempit from itset in tempit.DefaultIfEmpty() join usc in UserRepository.Entities on itset.CreateUserID equals usc.UserID into tempusc from uscu in tempusc.DefaultIfEmpty() join usm in UserRepository.Entities on itset.ModifyUserID equals usm.UserID into tempusm from usmu in tempusm.DefaultIfEmpty() select new InSchoolSettingView { InSchoolSettingID = itset.InSchoolSettingID == null ? Guid.Empty : itset.InSchoolSettingID, InSchoolStatusID = dicit.Value, InSchoolStatusName = dicit.Name, IsSelected = itset.IsSelected == null ? false : itset.IsSelected, IsDisplay = dicit.RecordStatus > (int)SYS_STATUS.UNUSABLE ? true : false, RecordStatus = itset.RecordStatus, CreateUserID = itset.CreateUserID, CreateUserName = uscu.Name, CreateTime = itset.CreateTime, ModifyUserID = itset.ModifyUserID, ModifyUserName = usmu.Name, ModifyTime = itset.ModifyTime }; return query; } /// /// 查询对应的在校状态设定信息View(设定表与对应的字典表信息内联) /// /// /// public IQueryable GetInSchoolSettingViewQueryable(Expression> exp) { var query = from set in InSchoolSettingRepository.GetList(exp) join dicit in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_InschoolStatus).Name) on set.InSchoolStatusID equals dicit.Value join usc in UserRepository.Entities on set.CreateUserID equals usc.UserID into tempusc from uscu in tempusc.DefaultIfEmpty() join usm in UserRepository.Entities on set.ModifyUserID equals usm.UserID into tempusm from usmu in tempusm.DefaultIfEmpty() select new InSchoolSettingView { InSchoolSettingID = set.InSchoolSettingID, InSchoolStatusID = dicit.Value, InSchoolStatusName = dicit.Name, IsSelected = set.IsSelected == null ? false : set.IsSelected, IsDisplay = dicit.RecordStatus > (int)SYS_STATUS.UNUSABLE ? true : false, RecordStatus = set.RecordStatus, CreateUserID = set.CreateUserID, CreateUserName = uscu.Name, CreateTime = set.CreateTime, ModifyUserID = set.ModifyUserID, ModifyUserName = usmu.Name, ModifyTime = set.ModifyTime }; return query; } } }