MinorGraduationStandardDAL.cs 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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.MinorGraduation.MinorGraduationSetting;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. namespace EMIS.DataLogic.MinorGraduation.MinorGraduationSetting
  10. {
  11. public class MinorGraduationStandardDAL
  12. {
  13. public MinorGraduationStandardRepository minorGraduationStandardRepository { get; set; }
  14. public CollegeRepository collegeRepository { get; set; }
  15. public GrademinorRepository grademinorRepository { get; set; }
  16. public MinorPlanRepository minorPlanRepository { get; set; }
  17. public ClassminorStudentRepository classminorStudentRepository { get; set; }
  18. public ClassminorRepository classminorRepository { get; set; }
  19. public IQueryable<MinorGraduationStandardView> GetMinorGraduationStandardView(Expression<Func<ER_MinorGraduationStandard, bool>> exp)
  20. {
  21. var query = from mgsr in minorGraduationStandardRepository.GetList(exp)
  22. join col in collegeRepository.Entities
  23. on mgsr.CollegeID equals col.CollegeID
  24. //join gmr in grademinorRepository.Entities
  25. //on new { mgsr.CollegeID, mgsr.YearID, mgsr.StandardID } equals new { gmr.CollegeID, gmr.YearID, gmr.StandardID }
  26. //join mpr in minorPlanRepository.Entities
  27. //on gmr.GrademinorID equals mpr.GrademinorID
  28. //group mpr by mpr.GrademinorID
  29. //into gmpr
  30. select new MinorGraduationStandardView
  31. {
  32. MinorGraduationStandardID = mgsr.MinorGraduationStandardID,
  33. CollegeID = col.CollegeID,
  34. CollegeNo = col.No,
  35. CollegeName = col.Name,
  36. YearID = mgsr.YearID,
  37. StandardID = mgsr.StandardID,
  38. GraduationCredit = mgsr.GraduationCredit,
  39. };
  40. return query;
  41. }
  42. public IQueryable<MinorGraduationStandardView> GetMinorGraduationStandardViewByUserID(Guid? userID)
  43. {
  44. var query = from clastu in classminorStudentRepository.GetList(x => x.UserID == userID)
  45. join cla in classminorRepository.Entities
  46. on clastu.ClassminorID equals cla.ClassminorID
  47. join gra in grademinorRepository.Entities
  48. on cla.GrademinorID equals gra.GrademinorID
  49. join mgsr in minorGraduationStandardRepository.Entities
  50. on new { gra.CollegeID, gra.YearID, gra.StandardID } equals new { mgsr.CollegeID, mgsr.YearID, mgsr.StandardID }
  51. join col in collegeRepository.Entities
  52. on mgsr.CollegeID equals col.CollegeID
  53. select new MinorGraduationStandardView
  54. {
  55. MinorGraduationStandardID = mgsr.MinorGraduationStandardID,
  56. CollegeID = col.CollegeID,
  57. CollegeNo = col.No,
  58. CollegeName = col.Name,
  59. YearID = mgsr.YearID,
  60. StandardID = mgsr.StandardID,
  61. GraduationCredit = mgsr.GraduationCredit,
  62. };
  63. return query;
  64. }
  65. }
  66. }