123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using EMIS.DataLogic.Repositories;
- using EMIS.ViewModel.SystemView;
- using EMIS.Entities;
- using EMIS.ViewModel;
- namespace EMIS.DataLogic.SystemDAL
- {
- public class RoleDAL
- {
- public RoleRepository RoleRepository { get; set; }
- public UserRepository UserRepository { get; set; }
- public DictionaryItemRepository DictionaryItemRepository { get; set; }
- public IQueryable<RoleView> GetRoleView(Expression<Func<Sys_Role, bool>> roleExpression)
- {
- var q = (from r in RoleRepository.GetList(roleExpression).OrderBy(c=>c.OrderNo).ThenBy(c=>c.TypeID)
- join dit in DictionaryItemRepository.Entities
- on new { DictionaryCode = typeof(SYS_RoleType).Name, Value = r.TypeID } equals new { dit.DictionaryCode, dit.Value }
- join didr in DictionaryItemRepository.Entities
- on new { DictionaryCode = typeof(SYS_DataRange).Name, Value = r.DefaultDataRange } equals new { didr.DictionaryCode, didr.Value } into ddidr
- from edidr in ddidr.DefaultIfEmpty()
- join dirs in DictionaryItemRepository.Entities
- on new { DictionaryCode = typeof(SYS_STATUS).Name, Value = r.RecordStatus } equals new { dirs.DictionaryCode, dirs.Value }
- join dist in DictionaryItemRepository.Entities
- on new { DictionaryCode = typeof(CF_STUDENTTYPE).Name, Value = r.CF_StudentRole.StudentType } equals new { dist.DictionaryCode, dist.Value } into ddist
- from edist in ddist.DefaultIfEmpty()
- join cu in UserRepository.Entities on r.CreateUserID equals cu.UserID into dcu
- from ecu in dcu.DefaultIfEmpty()
- join mu in UserRepository.Entities on r.ModifyUserID equals mu.UserID into dmu
- from emu in dmu.DefaultIfEmpty()
- select new RoleView
- {
- OrderNo = r.OrderNo,
- RoleID = r.RoleID,
- TypeID = r.TypeID,
- TypeDesc = dit.Name,
- RoleName = r.RoleName,
- Description = r.Description,
- IsSystemRole = r.IsSystemRole,
- SystemRoleType = r.SystemRoleType,
- DefaultDataRange = r.DefaultDataRange,
- DefaultDataRangeDesc = edidr.Name,
- StudentType = r.CF_StudentRole.StudentType,
- StudentTypeDesc = edist.Name,
- RecordStatus = r.RecordStatus,
- RecordStatusDesc = dirs.Name,
- CreateUserID = r.CreateUserID,
- CreateUserName = (ecu == null) ? null : ecu.Name,
- CreateTime = r.CreateTime,
- ModifyUserID = r.ModifyUserID,
- ModifyUserName = (emu == null) ? null : emu.Name,
- ModifyTime = r.ModifyTime
- });
- return q;
- }
- }
- }
|