ScoreConvertByReplaceDAL.cs 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using EMIS.DataLogic.Repositories;
  7. using EMIS.ViewModel.ScoreManage;
  8. using EMIS.Entities;
  9. namespace EMIS.DataLogic.ScoreManage
  10. {
  11. public class ScoreConvertByReplaceDAL
  12. {
  13. public CollegeRepository CollegeRepository { get; set; }
  14. public FacultymajorRepository FacultymajorRepository { get; set; }
  15. public GrademajorRepository GrademajorRepository { get; set; }
  16. public ClassmajorRepository ClassmajorRepository { get; set; }
  17. public StudentRepository StudentRepository { get; set; }
  18. public UserRepository UserRepository { get; set; }
  19. public SchoolyearRepository SchoolyearRepository { get; set; }
  20. public CoursematerialRepository CoursematerialRepository { get; set; }
  21. public ScoreConvertByReplaceRepository ScoreConvertByReplaceRepository { get; set; }
  22. public ScoreConvertedSubmitedScoreRepository ScoreConvertedSubmitedScoreRepository { get; set; }
  23. public IQueryable<ScoreConvertByReplaceView> GetScoreConvertByReplaceViewQueryable(Expression<Func<ER_ScoreConvertByReplace, bool>> exp,
  24. Expression<Func<CF_Facultymajor, bool>> facultyExp,
  25. Expression<Func<CF_Grademajor, bool>> gradeExp,
  26. Expression<Func<CF_Classmajor, bool>> classExp)
  27. {
  28. var sql = (from convert in ScoreConvertByReplaceRepository.GetList(exp)
  29. from user in UserRepository.Entities.Where(x => convert.UserID == x.UserID)
  30. from student in StudentRepository.Entities.Where(x => user.UserID == x.UserID)
  31. from classmajor in ClassmajorRepository.Entities.Where(classExp).Where(x => x.ClassmajorID == student.ClassmajorID)
  32. from grade in GrademajorRepository.Entities.Where(gradeExp).Where(x => classmajor.GrademajorID == x.GrademajorID)
  33. from faculty in FacultymajorRepository.Entities.Where(facultyExp).Where(x => grade.FacultymajorID == x.FacultymajorID)
  34. from college in CollegeRepository.Entities.Where(x => faculty.CollegeID == x.CollegeID)
  35. from schoolyear in SchoolyearRepository.Entities.Where(x => convert.SchoolyearID == x.SchoolyearID)
  36. from sourcecourse in CoursematerialRepository.Entities.Where(x => convert.SourceCoursematerialID == x.CoursematerialID)
  37. from targetcourse in CoursematerialRepository.Entities.Where(x => convert.TargetCoursematerialID == x.CoursematerialID)
  38. select new ScoreConvertByReplaceView
  39. {
  40. ScoreConvertByReplaceID = convert.ScoreConvertByReplaceID,
  41. SchoolyearID = convert.SchoolyearID,
  42. SchoolyearCode = schoolyear.Code,
  43. CollegeID = faculty.CollegeID,
  44. CollegeNo = college.No,
  45. CollegeName = college.Name,
  46. YearID = grade.GradeID,
  47. StandardID = faculty.StandardID,
  48. ClassmajorID = student.ClassmajorID,
  49. ClassmajorNo = classmajor.No,
  50. ClassmajorName = classmajor.Name,
  51. UserID = convert.UserID,
  52. LoginID = user.LoginID,
  53. Name = user.Name,
  54. SourceCoursematerialID = convert.SourceCoursematerialID,
  55. SourceCourseCode = sourcecourse.CourseCode,
  56. SourceCourseName = sourcecourse.CourseName,
  57. TotalScore = convert.TotalScore,
  58. TargetCoursematerialID = convert.TargetCoursematerialID,
  59. TargetCourseCode = targetcourse.CourseCode,
  60. TargetCourseName = targetcourse.CourseName,
  61. Reason = convert.Reason,
  62. RecordStatus = convert.RecordStatus
  63. });
  64. return sql;
  65. }
  66. }
  67. }