DepartmentDAL.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using EMIS.ViewModel;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. namespace EMIS.DataLogic.Common.AdministrativeOrgan
  10. {
  11. public class DepartmentDAL
  12. {
  13. public DepartmentRepository DepartmentRepository { get; set; }
  14. public DepartmentProfileRepository DepartmentProfileRepository { get; set; }
  15. public CollegeRepository CollegeRepository { get; set; }
  16. public UserRepository UserRepository { get; set; }
  17. public StaffRepository StaffRepository { get; set; }
  18. /// <summary>
  19. /// 查询对应的部门信息View
  20. /// </summary>
  21. /// <param name="expDepartment"></param>
  22. /// <returns></returns>
  23. public IQueryable<DepartmentView> GetDepartmentViewQueryable(Expression<Func<CF_Department, bool>> expDepartment)
  24. {
  25. var query = from dep in DepartmentRepository.GetList(expDepartment)
  26. join c in UserRepository.Entities
  27. on dep.CF_DepartmentProfile.DirectorID equals c.UserID
  28. into gu
  29. from guic in gu.DefaultIfEmpty()
  30. join d in UserRepository.Entities
  31. on dep.CF_DepartmentProfile.DeputyDirectorID equals d.UserID
  32. into gude
  33. from gudeic in gude.DefaultIfEmpty()
  34. select new DepartmentView
  35. {
  36. DepartmentID = dep.DepartmentID,
  37. No = dep.No,
  38. Name = dep.Name,
  39. SimpleName = dep.SimpleName,
  40. EnglishName = dep.EnglishName,
  41. CampusID = dep.CF_College.CampusID,
  42. CampusNo = dep.CF_College.CF_Campus.No,
  43. CampusName = dep.CF_College.CF_Campus.Name,
  44. CollegeID = dep.CollegeID,
  45. CollegeCode = dep.CF_College.No,
  46. CollegeName = dep.CF_College.Name,
  47. HierarchyID = dep.HierarchyID,
  48. DirectorID = dep.CF_DepartmentProfile.DirectorID,
  49. DirectorName = guic.Name,
  50. DeputyDirectorID = dep.CF_DepartmentProfile.DeputyDirectorID,
  51. DeputyDirectorName = gudeic.Name,
  52. FoundDate = dep.CF_DepartmentProfile.FoundDate,
  53. Remark = dep.Remark,
  54. RecordStatus = dep.RecordStatus,
  55. CreateUserID = dep.CreateUserID,
  56. CreateTime = dep.CreateTime,
  57. ModifyUserID = dep.ModifyUserID,
  58. ModifyTime = dep.ModifyTime
  59. };
  60. return query;
  61. }
  62. }
  63. }