using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EMIS.DataLogic.Repositories;
using EMIS.ViewModel;
using System.Linq.Expressions;
using EMIS.Entities;
namespace EMIS.DataLogic.Common.AdministrativeOrgan
{
public class DepartmentDAL
{
public DepartmentRepository DepartmentRepository { get; set; }
public DepartmentProfileRepository DepartmentProfileRepository { get; set; }
public CollegeRepository CollegeRepository { get; set; }
public UserRepository UserRepository { get; set; }
public StaffRepository StaffRepository { get; set; }
///
/// 查询对应的部门信息View
///
///
///
public IQueryable GetDepartmentViewQueryable(Expression> expDepartment)
{
var query = from dep in DepartmentRepository.GetList(expDepartment)
join c in UserRepository.Entities
on dep.CF_DepartmentProfile.DirectorID equals c.UserID
into gu
from guic in gu.DefaultIfEmpty()
join d in UserRepository.Entities
on dep.CF_DepartmentProfile.DeputyDirectorID equals d.UserID
into gude
from gudeic in gude.DefaultIfEmpty()
select new DepartmentView
{
DepartmentID = dep.DepartmentID,
No = dep.No,
Name = dep.Name,
SimpleName = dep.SimpleName,
EnglishName = dep.EnglishName,
CampusID = dep.CF_College.CampusID,
CampusNo = dep.CF_College.CF_Campus.No,
CampusName = dep.CF_College.CF_Campus.Name,
CollegeID = dep.CollegeID,
CollegeCode = dep.CF_College.No,
CollegeName = dep.CF_College.Name,
HierarchyID = dep.HierarchyID,
DirectorID = dep.CF_DepartmentProfile.DirectorID,
DirectorName = guic.Name,
DeputyDirectorID = dep.CF_DepartmentProfile.DeputyDirectorID,
DeputyDirectorName = gudeic.Name,
FoundDate = dep.CF_DepartmentProfile.FoundDate,
Remark = dep.Remark,
RecordStatus = dep.RecordStatus,
CreateUserID = dep.CreateUserID,
CreateTime = dep.CreateTime,
ModifyUserID = dep.ModifyUserID,
ModifyTime = dep.ModifyTime
};
return query;
}
}
}