ClassmajorDAL.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using EMIS.Entities;
  7. using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
  8. using EMIS.ViewModel.StudentManage.StudentProfile;
  9. using EMIS.DataLogic.Repositories;
  10. namespace EMIS.DataLogic.UniversityManage.SpecialtyClassManage
  11. {
  12. public class ClassmajorDAL
  13. {
  14. public ClassmajorRepository ClassmajorRepository { get; set; }
  15. public FacultymajorRepository FacultymajorRepository { get; set; }
  16. public GrademajorRepository GrademajorRepository { get; set; }
  17. public CollegeRepository CollegeRepository { get; set; }
  18. public CampusRepository CampusRepository { get; set; }
  19. public StudentRepository StudentRepository { get; set; }
  20. public UserRepository UserRepository { get; set; }
  21. /// <summary>
  22. /// 查询对应的班级信息View
  23. /// </summary>
  24. /// <param name="expClassmajor"></param>
  25. /// <returns></returns>
  26. public IQueryable<ClassmajorView> GetClassmajorViewQueryable(Expression<Func<CF_Classmajor, bool>> expClassmajor)
  27. {
  28. var query = from cl in ClassmajorRepository.GetList(expClassmajor)
  29. join gr in GrademajorRepository.Entities
  30. on cl.GrademajorID equals gr.GrademajorID
  31. join fa in FacultymajorRepository.Entities
  32. on gr.FacultymajorID equals fa.FacultymajorID
  33. join col in CollegeRepository.Entities
  34. on fa.CollegeID equals col.CollegeID
  35. join cam in CampusRepository.Entities
  36. on col.CampusID equals cam.CampusID
  37. join c in UserRepository.Entities
  38. on cl.UserID equals c.UserID into gu
  39. from guser in gu.DefaultIfEmpty()
  40. join d in UserRepository.Entities
  41. on cl.AssistantUserID equals d.UserID into ga
  42. from gassis in ga.DefaultIfEmpty()
  43. select new ClassmajorView
  44. {
  45. ClassmajorID = cl.ClassmajorID,
  46. No = cl.No,
  47. Name = cl.Name,
  48. Abbreviation = cl.Abbreviation,
  49. EnglishName = cl.EnglishName,
  50. ClassNum = cl.ClassNum,
  51. FacultymajorID = gr.FacultymajorID,
  52. FacultymajorCode = fa.Code,
  53. FacultymajorName = fa.Name,
  54. GrademajorID = cl.GrademajorID,
  55. GrademajorCode = gr.Code,
  56. GrademajorName = gr.Name,
  57. CampusID = col.CampusID,
  58. CampusNo = cam.No,
  59. CampusName = cam.Name,
  60. CollegeID = fa.CollegeID,
  61. CollegeCode = col.No,
  62. CollegeName = col.Name,
  63. GradeID = gr.GradeID,
  64. SemesterID = gr.SemesterID,
  65. StandardID = fa.StandardID,
  66. EducationID = fa.EducationID,
  67. LearningformID = fa.LearningformID,
  68. LearnSystem = fa.LearnSystem,
  69. GraduateSchoolyearID = gr.GraduateSchoolyearID,
  70. GraduateValue = gr.CF_Schoolyear.Value,
  71. GraduateSchoolyearCode = gr.CF_Schoolyear.Code,
  72. UserID = cl.UserID,
  73. UserName = guser.Name,
  74. AssistantUserID = cl.AssistantUserID,
  75. AssistantUserName = gassis.Name,
  76. Fixedclassroom = cl.Fixedclassroom,
  77. Remark = cl.Remark,
  78. RecordStatus = cl.RecordStatus,
  79. CreateUserID = cl.CreateUserID,
  80. CreateTime = cl.CreateTime,
  81. ModifyUserID = cl.ModifyUserID,
  82. ModifyTime = cl.ModifyTime
  83. };
  84. return query;
  85. }
  86. /// <summary>
  87. /// 查询对应的班级信息View(统计对应的学生人数)
  88. /// </summary>
  89. /// <param name="expClassmajor"></param>
  90. /// <param name="expStudent"></param>
  91. /// <returns></returns>
  92. public IQueryable<ClassmajorView> GetClassmajorViewQueryable(Expression<Func<CF_Classmajor, bool>> expClassmajor, Expression<Func<CF_Student, bool>> expStudent)
  93. {
  94. var query = from cl in ClassmajorRepository.GetList(expClassmajor)
  95. join gr in GrademajorRepository.Entities
  96. on cl.GrademajorID equals gr.GrademajorID
  97. join fa in FacultymajorRepository.Entities
  98. on gr.FacultymajorID equals fa.FacultymajorID
  99. join col in CollegeRepository.Entities
  100. on fa.CollegeID equals col.CollegeID
  101. join cam in CampusRepository.Entities
  102. on col.CampusID equals cam.CampusID
  103. join sc in
  104. (
  105. from sc in StudentRepository.GetList(expStudent)
  106. group sc by sc.CF_Classmajor.ClassmajorID into g
  107. select new
  108. {
  109. ClassmajorID = g.Key,
  110. StudentCount = g.Count()
  111. })
  112. on cl.ClassmajorID equals sc.ClassmajorID into dsc
  113. from esc in dsc.DefaultIfEmpty()
  114. join c in UserRepository.Entities
  115. on cl.UserID equals c.UserID into gu
  116. from guser in gu.DefaultIfEmpty()
  117. join d in UserRepository.Entities
  118. on cl.AssistantUserID equals d.UserID into ga
  119. from gassis in ga.DefaultIfEmpty()
  120. select new ClassmajorView
  121. {
  122. ClassmajorID = cl.ClassmajorID,
  123. No = cl.No,
  124. Name = cl.Name,
  125. Abbreviation = cl.Abbreviation,
  126. EnglishName = cl.EnglishName,
  127. ClassNum = cl.ClassNum,
  128. FacultymajorID = gr.FacultymajorID,
  129. FacultymajorCode = fa.Code,
  130. FacultymajorName = fa.Name,
  131. GrademajorID = cl.GrademajorID,
  132. GrademajorCode = gr.Code,
  133. GrademajorName = gr.Name,
  134. CampusID = col.CampusID,
  135. CampusNo = cam.No,
  136. CampusName = cam.Name,
  137. CollegeID = fa.CollegeID,
  138. CollegeCode = col.No,
  139. CollegeName = col.Name,
  140. GradeID = gr.GradeID,
  141. SemesterID = gr.SemesterID,
  142. StandardID = fa.StandardID,
  143. EducationID = fa.EducationID,
  144. LearningformID = fa.LearningformID,
  145. LearnSystem = fa.LearnSystem,
  146. GraduateSchoolyearID = gr.GraduateSchoolyearID,
  147. GraduateValue = gr.CF_Schoolyear.Value,
  148. GraduateSchoolyearCode = gr.CF_Schoolyear.Code,
  149. UserID = cl.UserID,
  150. UserName = guser.Name,
  151. AssistantUserID = cl.AssistantUserID,
  152. AssistantUserName = gassis.Name,
  153. Fixedclassroom = cl.Fixedclassroom,
  154. StudentCount = esc.StudentCount == null ? 0 : esc.StudentCount,
  155. Remark = cl.Remark,
  156. RecordStatus = cl.RecordStatus,
  157. CreateUserID = cl.CreateUserID,
  158. CreateTime = cl.CreateTime,
  159. ModifyUserID = cl.ModifyUserID,
  160. ModifyTime = cl.ModifyTime
  161. };
  162. return query;
  163. }
  164. /// <summary>
  165. /// 查询班级信息对应的学生信息BaseStudentView
  166. /// </summary>
  167. /// <param name="expClassmajor"></param>
  168. /// <param name="expStudent"></param>
  169. /// <returns></returns>
  170. public IQueryable<StudentBaseView> GetStudentBaseViewQueryable(Expression<Func<CF_Classmajor, bool>> expClassmajor, Expression<Func<CF_Student, bool>> expStudent)
  171. {
  172. var query = from cl in ClassmajorRepository.GetList(expClassmajor)
  173. join stu in StudentRepository.GetList(expStudent)
  174. on cl.ClassmajorID equals stu.ClassmajorID
  175. join gr in GrademajorRepository.Entities
  176. on cl.GrademajorID equals gr.GrademajorID
  177. join fa in FacultymajorRepository.Entities
  178. on gr.FacultymajorID equals fa.FacultymajorID
  179. join us in UserRepository.Entities
  180. on stu.UserID equals us.UserID
  181. select new StudentBaseView
  182. {
  183. UserID = stu.UserID,
  184. LoginID = us.LoginID,
  185. UserName = us.Name,
  186. SexID = stu.SexID,
  187. IDNumber = stu.IDNumber,
  188. StudentStatus = stu.StudentStatus,
  189. InSchoolStatusID = stu.InSchoolStatusID,
  190. ClassmajorID = stu.ClassmajorID,
  191. ClassmajorNo = cl.No,
  192. ClassmajorName = cl.Name,
  193. ClassNum = cl.ClassNum == null ? 1 : cl.ClassNum,
  194. GradeID = gr.GradeID,
  195. SemesterID = gr.SemesterID,
  196. GrademajorID = cl.GrademajorID,
  197. GrademajorCode = gr.Code,
  198. GrademajorName = gr.Name,
  199. FacultymajorID = gr.FacultymajorID,
  200. FacultymajorCode = fa.Code,
  201. FacultymajorName = fa.Name
  202. };
  203. return query;
  204. }
  205. }
  206. }