ExaminationMessageDAL.cs 4.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using EMIS.DataLogic.Repositories;
  2. using EMIS.Entities;
  3. using EMIS.ViewModel;
  4. using EMIS.ViewModel.EducationManage;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Linq.Expressions;
  9. using System.Text;
  10. namespace EMIS.DataLogic.EducationManage
  11. {
  12. public class ExaminationMessageDAL
  13. {
  14. public ExaminationRegistrationRepository ExaminationRegistrationRepository { get; set; }
  15. public ExaminationBatchProjectRepository ExaminationBatchProjectRepository { get; set; }
  16. public ExaminationProjectRepository ExaminationProjectRepository { get; set; }
  17. public ExaminationTypeRepository ExaminationTypeRepository { get; set; }
  18. public ExaminationBatchRepository ExaminationBatchRepository { get; set; }
  19. public SchoolyearRepository SchoolyearRepository { get; set; }
  20. public StudentRepository StudentRepository { get; set; }
  21. public ClassmajorRepository ClassmajorRepository { get; set; }
  22. public UserRepository UserRepository { get; set; }
  23. public GrademajorRepository GrademajorRepository { get; set; }
  24. public FacultymajorRepository FacultymajorRepository { get; set; }
  25. public CollegeRepository CollegeRepository { get; set; }
  26. public ExaminationMessageRepository ExaminationMessageRepository { get; set; }
  27. public IQueryable<ExaminationMessageView> GetExaminationMessageViewQueryable(Expression<Func<EX_ExaminationBatch, bool>> batchExp,
  28. Expression<Func<EX_ExaminationProject, bool>> projectExp, Expression<Func<CF_Facultymajor, bool>> facultyExp,
  29. Expression<Func<CF_Grademajor, bool>> gradeExp, Expression<Func<CF_Classmajor, bool>> classExp)
  30. {
  31. var sql = (from regist in ExaminationRegistrationRepository.Entities
  32. from batchProject in ExaminationBatchProjectRepository.Entities.Where(x => x.ExaminationBatchProjectID == regist.ExaminationBatchProjectID)
  33. from project in ExaminationProjectRepository.Entities.Where(projectExp).Where(x => x.ExaminationProjectID == batchProject.ExaminationProjectID)
  34. from type in ExaminationTypeRepository.Entities.Where(x => x.ExaminationTypeID == project.ExaminationTypeID)
  35. from batch in ExaminationBatchRepository.Entities.Where(batchExp).Where(x => x.ExaminationBatchID == batchProject.ExaminationBatchID)
  36. from schoolyear in SchoolyearRepository.Entities.Where(x => x.SchoolyearID == batch.SchoolyearID)
  37. from student in StudentRepository.Entities.Where(x => x.UserID == regist.UserID)
  38. from user in UserRepository.Entities.Where(x => x.UserID == student.UserID)
  39. from classmajor in ClassmajorRepository.Entities.Where(classExp).Where(x => x.ClassmajorID == student.ClassmajorID)
  40. from grade in GrademajorRepository.Entities.Where(gradeExp).Where(x => x.GrademajorID == classmajor.GrademajorID)
  41. from faculty in FacultymajorRepository.Entities.Where(facultyExp).Where(x => x.FacultymajorID == grade.FacultymajorID)
  42. from college in CollegeRepository.Entities.Where(x => x.CollegeID == faculty.CollegeID)
  43. from message in ExaminationMessageRepository.Entities.Where(x => x.ExaminationRegistrationID == regist.ExaminationRegistrationID).DefaultIfEmpty()
  44. where regist.RecordStatus == (int)EX_ExaminationRegistrationStatus.Paid
  45. select new ExaminationMessageView
  46. {
  47. ExaminationRegistrationID = regist.ExaminationRegistrationID,
  48. SchoolyearID = schoolyear.SchoolyearID,
  49. SchoolyearCode = schoolyear.Code,
  50. ExaminationBatchID = batch.ExaminationBatchID,
  51. ExaminationBatchName = batch.Name,
  52. ExaminationTypeID = type.ExaminationTypeID,
  53. ExaminationTypeName = type.Name,
  54. ExaminationProjectID = project.ExaminationProjectID,
  55. ExaminationProjectName = project.Name,
  56. ClassmajorID = classmajor.ClassmajorID,
  57. ClassmajorName = classmajor.Name,
  58. UserID = student.UserID,
  59. UserName = user.Name,
  60. Sex = student.Sex,
  61. StudentCardNo = student.StudentCardNo,
  62. CertificatesType = student.CertificatesType,
  63. IDNumber = student.IDNumber,
  64. ExaminationTime = message.ExaminationTime,
  65. Remark = message.Remark
  66. });
  67. return sql;
  68. }
  69. }
  70. }