CollegeDAL.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 CollegeDAL
  12. {
  13. public CollegeRepository CollegeRepository { get; set; }
  14. public CollegeProfileRepository CollegeProfileRepository { get; set; }
  15. public CampusRepository CampusRepository { get; set; }
  16. public UserRepository UserRepository { get; set; }
  17. public StaffRepository StaffRepository { get; set; }
  18. /// <summary>
  19. /// 查询对应的院系所信息CollegeView
  20. /// </summary>
  21. /// <returns></returns>
  22. public IQueryable<CollegeView> GetCollegeViewQueryable()
  23. {
  24. var query = from col in CollegeRepository.Entities
  25. from cam in CampusRepository.Entities.Where(x => x.CampusID == col.CampusID).DefaultIfEmpty()
  26. join e in UserRepository.Entities
  27. on col.CF_CollegeProfile.PoliticalManager equals e.UserID
  28. into gpm
  29. from gPoliticalManager in gpm.DefaultIfEmpty()
  30. join f in UserRepository.Entities
  31. on col.CF_CollegeProfile.AdministrativeManager equals f.UserID
  32. into gam
  33. from gAdministrativeManager in gam.DefaultIfEmpty()
  34. select new CollegeView
  35. {
  36. CollegeID = col.CollegeID,
  37. No = col.No,
  38. Name = col.Name,
  39. SimpleName = col.SimpleName,
  40. EnglishName = col.EnglishName,
  41. CampusID = col.CampusID,
  42. CampusNo = cam.No,
  43. CampusName = cam.Name,
  44. PoliticalManager = col.CF_CollegeProfile.PoliticalManager,
  45. PoliticalManagerName = gPoliticalManager.Name,
  46. AdministrativeManager = col.CF_CollegeProfile.AdministrativeManager,
  47. AdministrativeManagerName = gAdministrativeManager.Name,
  48. UnitCategoryID = col.CF_CollegeProfile.UnitCategoryID,
  49. CollegeTypeID = col.CF_CollegeProfile.CollegeTypeID,
  50. CollegeCategoryID = col.CF_CollegeProfile.CollegeCategoryID,
  51. RunByCategoryID = col.CF_CollegeProfile.RunByCategoryID,
  52. FoundDate = col.CF_CollegeProfile.FoundDate,
  53. Officephone = col.CF_CollegeProfile.Officephone,
  54. Remark = col.Remark,
  55. RecordStatus = col.RecordStatus,
  56. CreateUserID = col.CreateUserID,
  57. CreateTime = col.CreateTime,
  58. ModifyUserID = col.ModifyUserID,
  59. ModifyTime = col.ModifyTime
  60. };
  61. return query;
  62. }
  63. /// <summary>
  64. /// 查询对应的院系所信息CollegeView
  65. /// </summary>
  66. /// <param name="expCollege"></param>
  67. /// <returns></returns>
  68. public IQueryable<CollegeView> GetCollegeViewQueryable(Expression<Func<CF_College, bool>> expCollege)
  69. {
  70. var query = from col in CollegeRepository.GetList(expCollege)
  71. from cam in CampusRepository.Entities.Where(x => x.CampusID == col.CampusID).DefaultIfEmpty()
  72. join e in UserRepository.Entities
  73. on col.CF_CollegeProfile.PoliticalManager equals e.UserID
  74. into gpm
  75. from gPoliticalManager in gpm.DefaultIfEmpty()
  76. join f in UserRepository.Entities
  77. on col.CF_CollegeProfile.AdministrativeManager equals f.UserID
  78. into gam
  79. from gAdministrativeManager in gam.DefaultIfEmpty()
  80. select new CollegeView
  81. {
  82. CollegeID = col.CollegeID,
  83. No = col.No,
  84. Name = col.Name,
  85. SimpleName = col.SimpleName,
  86. EnglishName = col.EnglishName,
  87. CampusID = col.CampusID,
  88. CampusNo = cam.No,
  89. CampusName = cam.Name,
  90. PoliticalManager = col.CF_CollegeProfile.PoliticalManager,
  91. PoliticalManagerName = gPoliticalManager.Name,
  92. AdministrativeManager = col.CF_CollegeProfile.AdministrativeManager,
  93. AdministrativeManagerName = gAdministrativeManager.Name,
  94. UnitCategoryID = col.CF_CollegeProfile.UnitCategoryID,
  95. CollegeTypeID = col.CF_CollegeProfile.CollegeTypeID,
  96. CollegeCategoryID = col.CF_CollegeProfile.CollegeCategoryID,
  97. RunByCategoryID = col.CF_CollegeProfile.RunByCategoryID,
  98. FoundDate = col.CF_CollegeProfile.FoundDate,
  99. Officephone = col.CF_CollegeProfile.Officephone,
  100. Remark = col.Remark,
  101. RecordStatus = col.RecordStatus,
  102. CreateUserID = col.CreateUserID,
  103. CreateTime = col.CreateTime,
  104. ModifyUserID = col.ModifyUserID,
  105. ModifyTime = col.ModifyTime
  106. };
  107. return query;
  108. }
  109. /// <summary>
  110. /// 查询对应的院系所信息CollegeView(只显示院、系、部类别的院系所)
  111. /// </summary>
  112. /// <param name="expCollege"></param>
  113. /// <returns></returns>
  114. public IQueryable<CollegeView> GetOnlyCollegeViewQueryable(Expression<Func<CF_College, bool>> expCollege)
  115. {
  116. var query = from col in CollegeRepository.GetList(expCollege)
  117. from cam in CampusRepository.Entities.Where(x => x.CampusID == col.CampusID).DefaultIfEmpty()
  118. where col.CF_CollegeProfile.UnitCategoryID == (int)CF_UnitCategory.College
  119. select new CollegeView
  120. {
  121. CollegeID = col.CollegeID,
  122. No = col.No,
  123. Name = col.Name,
  124. SimpleName = col.SimpleName,
  125. EnglishName = col.EnglishName,
  126. CampusID = col.CampusID,
  127. CampusNo = cam.No,
  128. CampusName = cam.Name,
  129. UnitCategoryID = col.CF_CollegeProfile.UnitCategoryID,
  130. CollegeTypeID = col.CF_CollegeProfile.CollegeTypeID,
  131. CollegeCategoryID = col.CF_CollegeProfile.CollegeCategoryID,
  132. RunByCategoryID = col.CF_CollegeProfile.RunByCategoryID,
  133. FoundDate = col.CF_CollegeProfile.FoundDate,
  134. Officephone = col.CF_CollegeProfile.Officephone,
  135. Remark = col.Remark,
  136. RecordStatus = col.RecordStatus,
  137. CreateUserID = col.CreateUserID,
  138. CreateTime = col.CreateTime,
  139. ModifyUserID = col.ModifyUserID,
  140. ModifyTime = col.ModifyTime
  141. };
  142. return query;
  143. }
  144. }
  145. }