MisconductDAL.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.ScoreManage;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. using EMIS.ViewModel.Cultureplan;
  11. using EMIS.DataLogic.Common.Cultureplan;
  12. namespace EMIS.DataLogic.ScoreManage
  13. {
  14. public class MisconductDAL
  15. {
  16. public MisconductRepository MisconductRepository { get; set; }
  17. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  18. public EducationMissionRepository EducationMissionRepository { get; set; }
  19. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  20. public SchoolyearRepository SchoolyearRepository { get; set; }
  21. public StudentRepository StudentRepository { get; set; }
  22. public FinalExaminationRepository FinalExaminationRepository { get; set; }
  23. public CoursematerialRepository CoursematerialRepository { get; set; }
  24. public Lazy<CoursematerialDAL> CoursematerialDAL { get; set; }
  25. public IQueryable<MisconductView> GetMisconductViewQueryable(Expression<Func<ER_Misconduct, bool>> exp)
  26. {
  27. var query = (from m in MisconductRepository.GetList(exp)
  28. select new MisconductView
  29. {
  30. MisconductID = m.MisconductID,
  31. UserID = m.UserID,
  32. LoginID = m.CF_Student.Sys_User.LoginID,
  33. Name = m.CF_Student.Sys_User.Name,
  34. ClassmajorName = m.CF_Student.CF_Classmajor.Name,
  35. CollegeID = m.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID,
  36. Year = m.CF_Student.CF_Classmajor.CF_Grademajor.GradeID,
  37. StandardID = m.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID,
  38. SchoolyearID = m.SchoolyearID,
  39. SchoolyearCode = m.CF_Schoolyear.Code,
  40. CoursematerialID = m.CoursematerialID,
  41. CourseCode = m.EM_Coursematerial.CourseCode,
  42. CourseName = m.EM_Coursematerial.CourseName,
  43. ExamsCategoryID = m.ExamsCategoryID,
  44. ExamsStateID = m.ExamsStateID,
  45. Reason = m.Reason,
  46. RecordStatus = m.RecordStatus,
  47. CreateTime = m.CreateTime
  48. });
  49. return query;
  50. }
  51. public IQueryable<CoursematerialView> GetMisconductCoursematerialViewQueryable(Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> schoolyearExp,
  52. Expression<Func<CF_Student, bool>> studentExp)
  53. {
  54. var coursematerialIDQuery = (
  55. from emc in EducationMissionClassRepository.Entities
  56. join em in EducationMissionRepository.Entities on emc.EducationMissionID equals em.EducationMissionID
  57. join cm in CoursematerialRepository.Entities on emc.CoursematerialID equals cm.CoursematerialID
  58. join sy in SchoolyearRepository.GetList(schoolyearExp)
  59. on em.SchoolyearID equals sy.SchoolyearID
  60. from esc in emc.EM_EducationSchedulingClass
  61. from esccs in esc.CF_Student
  62. join s in StudentRepository.GetList(studentExp) on esccs.UserID equals s.UserID
  63. group emc by new { emc.CoursematerialID, cm.CourseCode, cm.CourseName } into g
  64. select new { CoursematerialID = g.Key.CoursematerialID }
  65. ).Concat(
  66. from fe in FinalExaminationRepository.Entities
  67. join sy in SchoolyearRepository.GetList(schoolyearExp) on fe.SchoolyearID equals sy.SchoolyearID
  68. from fes in fe.ER_FinalExaminationStudent
  69. join s in StudentRepository.GetList(studentExp) on fes.UserID equals s.UserID
  70. group fe by fe.CoursematerialID into g
  71. select new { CoursematerialID = g.Key }
  72. );
  73. var query = (from cid in coursematerialIDQuery.Distinct()
  74. join cmv in CoursematerialDAL.Value.GetCoursematerialViewQueryable(x => true) on cid.CoursematerialID equals cmv.CoursematerialID
  75. select cmv);
  76. return query;
  77. }
  78. }
  79. }