MinorSpecialtyDAL.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.MinorManage.MinorPlanManage;
  7. using EMIS.Entities;
  8. using System.Linq.Expressions;
  9. using EMIS.ViewModel.Students;
  10. namespace EMIS.DataLogic.MinorManage.MinorPlanManage
  11. {
  12. public class MinorSpecialtyDAL
  13. {
  14. public GrademinorRepository GrademinorRepository { get; set; }
  15. public UserRepository UserRepository { get; set; }
  16. public CollegeRepository CollegeRepository { get; set; }
  17. public SchoolyearRepository SchoolyearRepository { get; set; }
  18. public StudentMinorRegistRepository studentMinorRegistRepository { get; set; }
  19. public StudentRepository studentRepository { get; set; }
  20. public ClassmajorRepository classmajorRepository { get; set; }
  21. public GrademajorRepository grademajorRepository { get; set; }
  22. public FacultymajorRepository facultymajorRepository { get; set; }
  23. public CollegeRepository collegeRepository { get; set; }
  24. public IQueryable<MinorSpecialtyView> GetMinorSpecialtyViewQueryable(Expression<Func<CF_Grademinor, bool>> exp)
  25. {
  26. var query = from Grademinor in GrademinorRepository.GetList(exp)
  27. join User in UserRepository.Entities on Grademinor.CreateUserID equals User.UserID into user
  28. from u in user.DefaultIfEmpty()
  29. join College in CollegeRepository.Entities on Grademinor.CollegeID equals College.CollegeID
  30. join schoolYear in SchoolyearRepository.Entities on Grademinor.SchoolyearID equals schoolYear.SchoolyearID
  31. select new MinorSpecialtyView
  32. {
  33. GrademinorID=Grademinor.GrademinorID,
  34. GradeMinorApplicationID = Grademinor.GrademinorApplicationID,
  35. YearID = Grademinor.YearID,
  36. SchoolyearID = Grademinor.SchoolyearID,
  37. SchoolyearCode=schoolYear.Code,
  38. StandardID = Grademinor.StandardID,
  39. CollegeID = Grademinor.CollegeID,
  40. CollegeName = College.Name,
  41. CollegeNo = College.No,
  42. StudentLimit = Grademinor.StudentLimit,
  43. OpenStatus = Grademinor.RecordStatus,
  44. CreateUserID = Grademinor.CreateUserID,
  45. CreateTime = Grademinor.CreateTime,
  46. CreateUserName = u.Name,
  47. StudentCount = Grademinor.EM_StudentMinorRegist.GroupBy(x => x.UserID).Count(),
  48. };
  49. return query;
  50. }
  51. public IQueryable<StudentsView> GetStudentsQueryable(Expression<Func<EM_StudentMinorRegist, bool>> exp)
  52. {
  53. var query = from stumrr in studentMinorRegistRepository.GetList(exp)
  54. group stumrr by stumrr.UserID
  55. into gstu
  56. join user in UserRepository.Entities
  57. on gstu.Key equals user.UserID
  58. join stu in studentRepository.Entities
  59. on gstu.Key equals stu.UserID
  60. join cla in classmajorRepository.Entities
  61. on stu.ClassmajorID equals cla.ClassmajorID
  62. join gra in grademajorRepository.Entities
  63. on cla.GrademajorID equals gra.GrademajorID
  64. join fac in facultymajorRepository.Entities
  65. on gra.FacultymajorID equals fac.FacultymajorID
  66. join col in collegeRepository.Entities
  67. on fac.CollegeID equals col.CollegeID
  68. select new StudentsView
  69. {
  70. CollegeID = col.CollegeID,
  71. CollegeName = col.Name,
  72. CollegeCode = col.No,
  73. GradeMajorID = gra.GrademajorID,
  74. GradeMajorCode = gra.Code,
  75. GradeMajorName = gra.Name,
  76. ClassMajorID = cla.GrademajorID,
  77. ClassMajorName = cla.Name,
  78. ClassMajorCode = cla.No,
  79. LoginID = user.LoginID,
  80. UserName = user.Name,
  81. UserID = user.UserID,
  82. };
  83. return query;
  84. }
  85. }
  86. }