using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using EMIS.Entities;
using EMIS.ViewModel;
using EMIS.ViewModel.StudentManage.StudentChange;
using EMIS.DataLogic.Repositories;
namespace EMIS.DataLogic.StudentManage.StudentChange
{
public class ChangeTypeSettingDAL
{
public DifferentDynamicTypeInOutSettingRepository ChangeTypeInOutSettingRepository { get; set; }
public DictionaryItemRepository DictionaryItemRepository { get; set; }
public UserRepository UserRepository { get; set; }
///
/// 查询对应的异动类型设定信息View(对应的字典表信息左连设定表)
///
///
///
///
public IQueryable GetChangeTypeSettingViewQueryable(Expression> expDictionaryItem,
Expression> expChangeTypeInOutSetting)
{
var query = from dicit in DictionaryItemRepository.GetList(expDictionaryItem)
join set in ChangeTypeInOutSettingRepository.GetList(expChangeTypeInOutSetting)
on dicit.Value equals set.ChangeTypeID 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 ChangeTypeSettingView
{
ChangeTypeInOutSettingID = itset.ChangeTypeInOutSettingID == null ? Guid.Empty : itset.ChangeTypeInOutSettingID,
ChangeTypeID = dicit.Value,
ChangeTypeName = dicit.Name,
IsIn = itset.IsIn == null ? false : itset.IsIn,
IsOut = itset.IsOut == null ? false : itset.IsOut,
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 GetChangeTypeSettingViewQueryable(Expression> exp)
{
var query = from set in ChangeTypeInOutSettingRepository.GetList(exp)
join dicit in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_ChangeType).Name)
on set.ChangeTypeID 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 ChangeTypeSettingView
{
ChangeTypeInOutSettingID = set.ChangeTypeInOutSettingID,
ChangeTypeID = dicit.Value,
ChangeTypeName = dicit.Name,
IsIn = set.IsIn == null ? false : set.IsIn,
IsOut = set.IsOut == null ? false : set.IsOut,
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;
}
}
}