ResitDAL.cs 4.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. namespace EMIS.DataLogic.ScoreManage
  10. {
  11. public class ResitDAL
  12. {
  13. public ResitRepository ResitRepository { get; set; }
  14. public SchoolyearRepository SchoolyearRepository { get; set; }
  15. public ExaminationScoreRepository ExaminationScoreRepository { get; set; }
  16. public ExaminationBatchProjectRepository ExaminationBatchProjectRepository { get; set; }
  17. public ExaminationBatchRepository ExaminationBatchRepository { get; set; }
  18. public ExaminationTypeRepository ExaminationTypeRepository { get; set; }
  19. public ExaminationProjectRepository ExaminationProjectRepository { get; set; }
  20. public StudentRepository StudentRepository { get; set; }
  21. public UserRepository UserRepository { get; set; }
  22. public ClassmajorRepository ClassmajorRepository { get; set; }
  23. public GrademajorRepository GrademajorRepository { get; set; }
  24. public FacultymajorRepository FacultymajorRepository { get; set; }
  25. public CollegeRepository CollegeRepository { get; set; }
  26. public IQueryable<ResitView> GetResitViewQueryable(Expression<Func<EX_ExaminationBatch, bool>> batchExp,
  27. Expression<Func<EX_ExaminationProject, bool>> projectExp, Expression<Func<ER_ExaminationScore, bool>> scoreExp,
  28. Expression<Func<CF_Facultymajor, bool>> facutyExp, Expression<Func<CF_Grademajor, bool>> gradeExp,
  29. Expression<Func<CF_Student, bool>> studentExp)
  30. {
  31. var sql = (from resit in ResitRepository.Entities
  32. from score in ExaminationScoreRepository.Entities.Where(scoreExp).Where(x => x.ExaminationScoreID == resit.ExaminationScoreID)
  33. from batchProject in ExaminationBatchProjectRepository.Entities.Where(x => x.ExaminationBatchProjectID == score.ExaminationBatchProjectID)
  34. from batch in ExaminationBatchRepository.Entities.Where(batchExp).Where(x => x.ExaminationBatchID == batchProject.ExaminationBatchID)
  35. from schoolyear in SchoolyearRepository.Entities.Where(x => x.SchoolyearID == batch.SchoolyearID)
  36. from project in ExaminationProjectRepository.Entities.Where(projectExp).Where(x => x.ExaminationProjectID == batchProject.ExaminationProjectID)
  37. from type in ExaminationTypeRepository.Entities.Where(x => x.ExaminationTypeID == project.ExaminationTypeID)
  38. from student in StudentRepository.Entities.Where(studentExp).Where(x => x.UserID == score.UserID)
  39. from user in UserRepository.Entities.Where(x => x.UserID == student.UserID)
  40. from classmajor in ClassmajorRepository.Entities.Where(x => x.ClassmajorID == student.ClassmajorID)
  41. from grade in GrademajorRepository.Entities.Where(gradeExp).Where(x => x.GrademajorID == classmajor.GrademajorID)
  42. from faculty in FacultymajorRepository.Entities.Where(facutyExp).Where(x => x.FacultymajorID == grade.FacultymajorID)
  43. from college in CollegeRepository.Entities.Where(x => x.CollegeID == faculty.CollegeID)
  44. select new ResitView
  45. {
  46. ResitID = resit.ResitID,
  47. ExaminationScoreID = resit.ExaminationScoreID,
  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. ExaminationSubjectID = score.ExaminationSubjectID,
  57. CollegeID = college.CollegeID,
  58. CollegeName = college.Name,
  59. Year = grade.SchoolyearID,
  60. StandardID = faculty.StandardID,
  61. ClassmajorID = classmajor.ClassmajorID,
  62. ClassmajorName = classmajor.Name,
  63. UserID = user.UserID,
  64. UserName = user.Name,
  65. CertificatesType = student.CertificatesType,
  66. IDNumber = student.IDNumber,
  67. Score = score.Score,
  68. Expire = score.Expire,
  69. SchoolAreaID = grade.SchoolAreaID,
  70. });
  71. return sql;
  72. }
  73. }
  74. }