MinorClassDAL.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using System.Linq.Expressions;
  7. using EMIS.Entities;
  8. using EMIS.ViewModel.MinorManage.MinorClass;
  9. using EMIS.ViewModel.MinorManage.MinorApply;
  10. using EMIS.ViewModel.Students;
  11. namespace EMIS.DataLogic.MinorManage.MinorClass
  12. {
  13. public class MinorClassDAL
  14. {
  15. public ClassminorRepository classminorRepository { get; set; }
  16. public GrademinorRepository grademinorRepository { get; set; }
  17. public SchoolyearRepository schoolyearRepository { get; set; }
  18. public CollegeRepository collegeRepository { 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 StudentMinorRegistRepository studentMinorRegistRepository { get; set; }
  24. public GrademinorApplicationRepository grademinorApplicationRepository { get; set; }
  25. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  26. public ClassminorStudentRepository classminorStudentRepository { get; set; }
  27. public UserRepository userRepository { get; set; }
  28. public IQueryable<MinorClassView> GetMinorClassViewQueryable(Expression<Func<CF_Classminor, bool>> exp, Expression<Func<CF_Grademinor, bool>> expgm)
  29. {
  30. var query = from cr in classminorRepository.GetList(exp)
  31. join gr in grademinorRepository.GetList(expgm)
  32. on cr.GrademinorID equals gr.GrademinorID
  33. join sr in schoolyearRepository.Entities
  34. on gr.SchoolyearID equals sr.SchoolyearID
  35. join col in collegeRepository.Entities
  36. on gr.CollegeID equals col.CollegeID
  37. select new MinorClassView
  38. {
  39. ClassminorID = cr.ClassminorID,
  40. GrademinorID = cr.GrademinorID,
  41. SchoolyearID = gr.SchoolyearID,
  42. SchoolyearCode = sr.Code,
  43. GradeYearID = gr.YearID,
  44. StandardID = gr.StandardID,
  45. Name = cr.Name,
  46. StudentNum = cr.CF_ClassminorStudent.Count,
  47. CF_ClassminorStudent = cr.CF_ClassminorStudent,
  48. RecordStatus = cr.RecordStatus
  49. };
  50. return query;
  51. }
  52. public IQueryable<StudentsView> GetStudentsQueryable(Expression<Func<CF_ClassminorStudent, bool>> exp)
  53. {
  54. var query = from clastu in classminorStudentRepository.GetList(exp)
  55. join user in userRepository.Entities
  56. on clastu.UserID equals user.UserID
  57. join stu in studentRepository.Entities
  58. on clastu.UserID equals stu.UserID
  59. join cla in classmajorRepository.Entities
  60. on stu.ClassmajorID equals cla.ClassmajorID
  61. join gra in grademajorRepository.Entities
  62. on cla.GrademajorID equals gra.GrademajorID
  63. join fac in facultymajorRepository.Entities
  64. on gra.FacultymajorID equals fac.FacultymajorID
  65. join col in collegeRepository.Entities
  66. on fac.CollegeID equals col.CollegeID
  67. select new StudentsView
  68. {
  69. CollegeID = col.CollegeID,
  70. CollegeName = col.Name,
  71. CollegeCode = col.No,
  72. GradeMajorID = gra.GrademajorID,
  73. GradeMajorCode = gra.Code,
  74. GradeMajorName = gra.Name,
  75. ClassMajorID = cla.GrademajorID,
  76. ClassMajorName = cla.Name,
  77. ClassMajorCode = cla.No,
  78. LoginID = user.LoginID,
  79. UserName = user.Name,
  80. UserID = user.UserID,
  81. };
  82. return query;
  83. }
  84. public IQueryable<CF_Grademinor> GetGrademinor()
  85. {
  86. var query = from gr in grademinorRepository.Entities
  87. select new CF_Grademinor
  88. {
  89. GrademinorID = gr.GrademinorID,
  90. SchoolyearID = gr.SchoolyearID,
  91. CollegeID = gr.CollegeID,
  92. YearID = gr.YearID,
  93. };
  94. return query;
  95. }
  96. }
  97. }