StudentQuitReasonDAL.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.ViewModel.Students.HighBaseTable;
  6. using EMIS.DataLogic.Repositories;
  7. using EMIS.ViewModel;
  8. namespace EMIS.DataLogic.Common.Students.HighBaseTable
  9. {
  10. public class StudentQuitReasonDAL
  11. {
  12. public DifferentDynamicRepository DifferentDynamicRepository { get; set; }
  13. public StudentRepository StudentRepository { get; set; }
  14. public ClassmajorRepository ClassmajorRepository { get; set; }
  15. public GrademajorRepository GrademajorRepository { get; set; }
  16. public FacultymajorRepository FacultymajorRepository { get; set; }
  17. public EducationTypeSettingRepository EducationTypeSettingRepository { get; set; }
  18. public SchoolyearRepository SchoolyearRepository { get; set; }
  19. public StudentChangeReasonTypeDetailRepository StudentChangeReasonTypeDetailRepository { get; set; }
  20. public IQueryable<StudentQuitStudentCountView> GetStudentQuitStudentCount(int year, int? differentDynamicEndStatusID)
  21. {
  22. var differentDynamicTypeIDList = new List<int>
  23. {
  24. (int)CF_ChangeType.Dismiss,
  25. (int)CF_ChangeType.Quit
  26. };
  27. var q = (
  28. from change in DifferentDynamicRepository.GetList(x => x.ApprovalStatus == differentDynamicEndStatusID && x.AfterClassmajorID == null)
  29. join student in StudentRepository.Entities on change.UserID equals student.UserID
  30. join classmajor in ClassmajorRepository.Entities on student.ClassmajorID equals classmajor.ClassmajorID
  31. join grade in GrademajorRepository.Entities on classmajor.GrademajorID equals grade.GrademajorID
  32. join faculty in FacultymajorRepository.Entities on grade.FacultymajorID equals faculty.FacultymajorID
  33. join educationType in EducationTypeSettingRepository.Entities on faculty.EducationID equals educationType.EducationID
  34. join schoolyear in SchoolyearRepository.Entities on change.SchoolyearID equals schoolyear.SchoolyearID
  35. join reasonType in StudentChangeReasonTypeDetailRepository.Entities on change.ChangeReasonID equals reasonType.DifferentDynamicReason
  36. into dreasonType
  37. from reasonType in dreasonType.DefaultIfEmpty()
  38. where schoolyear.Years == year && differentDynamicTypeIDList.Contains(change.ChangeTypeID.Value)
  39. group change by new { educationType.EducationTypeID, reasonType.StudentChangeReasonTypeID } into g
  40. select new StudentQuitStudentCountView
  41. {
  42. EducationTypeID = g.Key.EducationTypeID,
  43. StudentChangeReasonTypeID = g.Key.StudentChangeReasonTypeID,
  44. StudentCount = g.Sum(x => 1)
  45. }
  46. );
  47. return q;
  48. }
  49. }
  50. }