RecruitTerritorialReportDAL.cs 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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.Students.HighBaseTable;
  7. using EMIS.ViewModel;
  8. namespace EMIS.DataLogic.Common.Students.HighBaseTable
  9. {
  10. public class RecruitTerritorialReportDAL
  11. {
  12. public SchoolyearRepository SchoolyearRepository { get; set; }
  13. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  14. public InSchoolSettingRepository InSchoolSettingRepository { get; set; }
  15. public EducationTypeSettingRepository EducationTypeSettingRepository { get; set; }
  16. public ExamineeTypeSettingRepository ExamineeTypeSettingRepository { get; set; }
  17. public FeaturesSettingRepository FeaturesSettingRepository { get; set; }
  18. public ClassmajorRepository ClassmajorRepository { get; set; }
  19. public GrademajorRepository GrademajorRepository { get; set; }
  20. public FacultymajorRepository FacultymajorRepository { get; set; }
  21. public StudentRepository StudentRepository { get; set; }
  22. public RecruitstudentsRepository RecruitstudentsRepository { get; set; }
  23. public IQueryable<RecruitTerritorialReportView> GetRecruitTerritorialReportView(int year)
  24. {
  25. var sql = (from student in StudentRepository.Entities
  26. join inschool in InSchoolSettingRepository.Entities.Where(x => x.IsSelected == true)
  27. on student.InSchoolStatusID equals inschool.InSchoolStatusID
  28. join recruit in RecruitstudentsRepository.Entities on student.UserID equals recruit.UserID
  29. join schoolyear in SchoolyearRepository.Entities.Where(x => x.Years == year)
  30. on recruit.EnteringSchoolYearID equals schoolyear.SchoolyearID
  31. join classmajor in ClassmajorRepository.Entities on student.ClassmajorID equals classmajor.ClassmajorID
  32. join grade in GrademajorRepository.Entities on classmajor.GrademajorID equals grade.GrademajorID
  33. join faculty in FacultymajorRepository.Entities on grade.FacultymajorID equals faculty.FacultymajorID
  34. join territorial in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Province).Name)
  35. on recruit.TerritorialID equals territorial.Value into dterritorial
  36. from territorial in dterritorial.DefaultIfEmpty()
  37. join educationType in EducationTypeSettingRepository.Entities
  38. .Where(x => x.EducationTypeID == (int)CF_EducationType.Special)
  39. on faculty.EducationID equals educationType.EducationID
  40. join recruitCategory in FeaturesSettingRepository.Entities on recruit.FeaturesID equals recruitCategory.FeaturesID into drecruitCategory
  41. from recruitCategory in drecruitCategory.DefaultIfEmpty()
  42. join examineeType in ExamineeTypeSettingRepository.Entities on recruit.ExamineeType equals examineeType.ExamineeTypeID into dexamineeType
  43. from examineeType in dexamineeType.DefaultIfEmpty()
  44. group student by new { Territorial = territorial.Value, educationType.EducationTypeID, recruitCategory.RecruitCategoryID, examineeType.IsFreshGraduate, examineeType.IsCountry } into g
  45. select new RecruitTerritorialReportView
  46. {
  47. Year = year,
  48. Territorial = g.Key.Territorial,
  49. EducationTypeID = g.Key.EducationTypeID,
  50. RecruitCategoryID = g.Key.RecruitCategoryID,
  51. IsFreshGraduate = g.Key.IsFreshGraduate,
  52. IsCountry = g.Key.IsCountry,
  53. RecruitCount = g.Count()
  54. }
  55. );
  56. return sql;
  57. }
  58. }
  59. }