using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using EMIS.Entities; using EMIS.ViewModel.EvaluationManage.EvaluationTable; using EMIS.DataLogic.Repositories; namespace EMIS.DataLogic.EvaluationManage.EvaluationTable { public class EvaluationTargetDAL { public EvaluationTargetRepository EvaluationTargetRepository { get; set; } public EvaluationTableRepository EvaluationTableRepository { get; set; } public EvaluationNormRepository EvaluationNormRepository { get; set; } public EvaluationParticipateTypeRepository EvaluationParticipateTypeRepository { get; set; } public EvaluationIntTypeRepository EvaluationIntTypeRepository { get; set; } public EvaluationProjectRepository EvaluationProjectRepository { get; set; } public UserRepository UserRepository { get; set; } /// /// 查询对应的评价指标信息EvaluationTargetView /// /// /// public IQueryable GetEvaluationTargetViewQueryable(Expression> exp) { var query = from evtg in EvaluationTargetRepository.GetList(exp) join evtb in EvaluationTableRepository.Entities on evtg.EvaluationTableID equals evtb.EvaluationTableID join evnm in EvaluationNormRepository.Entities on evtg.EvaluationNormID equals evnm.EvaluationNormID join evpt in EvaluationParticipateTypeRepository.Entities on evtb.EvaluationParticipateTypeID equals evpt.EvaluationParticipateTypeID join evit in EvaluationIntTypeRepository.Entities on evtb.EvaluationIntTypeID equals evit.EvaluationIntTypeID join pj in ( from pj in EvaluationProjectRepository.Entities group pj by pj.EvaluationTargetID into gpj select new { EvaluationTargetID = gpj.Key, ProjectCount = gpj.Count() } ) on evtg.EvaluationTargetID equals pj.EvaluationTargetID into temppj from evpj in temppj.DefaultIfEmpty() join usc in UserRepository.Entities on evtg.CreateUserID equals usc.UserID into tempusc from uscu in tempusc.DefaultIfEmpty() join usm in UserRepository.Entities on evtg.ModifyUserID equals usm.UserID into tempusm from usmu in tempusm.DefaultIfEmpty() select new EvaluationTargetView { EvaluationTargetID = evtg.EvaluationTargetID, OrderNo = evtg.OrderNo, Code = evtg.Code, Name = evtg.Name, EvaluationTableID = evtg.EvaluationTableID, EvaluationTableCode = evtb.Code, EvaluationTableName = evtb.Name, EvaluationTableWeight = evtb.Weight, EvaluationParticipateTypeID = evtb.EvaluationParticipateTypeID, ParticipateTypeID = evpt.ParticipateTypeID, IsStudent = evpt.IsStudent.Value, EvaluationTypeID = evtb.EvaluationIntTypeID, EvaluationTypeCode = evit.Code, EvaluationTypeName = evit.Name, TeachingModeIDList = evit.EM_EvaluationTeachingMode.OrderBy(x => x.TeachingModeID).Select(x => x.TeachingModeID).ToList(), EvaluationNormID = evtg.EvaluationNormID, EvaluationNormName = evnm.Name, NormTypeID = evnm.NormTypeID, Weight = evtg.Weight, ProjectCount = evpj.ProjectCount == null ? 0 : evpj.ProjectCount, Remark = evtg.Remark, RecordStatus = evtg.RecordStatus, CreateUserID = evtg.CreateUserID, CreateUserName = uscu.Name, CreateTime = evtg.CreateTime, ModifyUserID = evtg.ModifyUserID, ModifyUserName = usmu.Name, ModifyTime = evtg.ModifyTime }; return query; } } }