LevelScoreDAL.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 EMIS.Entities;
  8. using System.Linq.Expressions;
  9. namespace EMIS.DataLogic.ScoreManage
  10. {
  11. public class LevelScoreDAL
  12. {
  13. public LevelScoreRepository levelScoreRepository { get; set; }
  14. public LevelSettingRepository levelSettingRepository { get; set; }
  15. public StudentRepository studentRepository { get; set; }
  16. public ClassmajorRepository classmajorRepository { get; set; }
  17. public CollegeRepository collegeRepository { get; set; }
  18. public ExaminationSubjectRepository examinationSubjectRepository { get; set; }
  19. public IQueryable<LevelScoreView> GetLevelScoreViewQueryable(Expression<Func<ER_LevelScore, bool>> exp)
  20. {
  21. var query = from a in levelScoreRepository.GetList(exp)
  22. join b in studentRepository.Entities on a.UserID equals b.UserID
  23. join c in classmajorRepository.Entities on b.ClassmajorID equals c.ClassmajorID
  24. join d in examinationSubjectRepository.Entities on a.ExaminationSubjectID equals d.ExaminationSubjectID
  25. //join e in levelSettingRepository.Entities on new { a.ExaminationSubjectID } equals new { e.ExaminationSubjectID }
  26. //into tmp
  27. //from ae in tmp.Where(x => a.TotalScore <= x.MaxScore && a.TotalScore >= x.MinScore).DefaultIfEmpty()
  28. //into tmp from ae in tmp.DefaultIfEmpty()
  29. select new LevelScoreView
  30. {
  31. LevelScoreID = a.LevelScoreID,
  32. UserName = b.Sys_User.Name,
  33. UserID = a.UserID,
  34. LoginID = b.Sys_User.LoginID,
  35. StudentCardNo = b.StudentCardNo,
  36. SchoolyearID = a.SchoolyearID,
  37. SchoolyearCode = a.CF_Schoolyear.Code,
  38. Years = c.CF_Grademajor.GradeID,
  39. ClassmajorID = c.ClassmajorID,
  40. ClassmajorName = c.Name,
  41. CollegeID = c.CF_Grademajor.CF_Facultymajor.CollegeID,
  42. CollegeName = c.CF_Grademajor.CF_Facultymajor.CF_College.Name,
  43. StandardID = c.CF_Grademajor.CF_Facultymajor.StandardID,
  44. ExaminationSubjectID = a.ExaminationSubjectID,
  45. ExaminationSubjectName = d.Name,
  46. ScoreNo = a.ScoreNo,
  47. TotalScore = a.TotalScore,
  48. ExaminationDate = a.ExaminationDate,
  49. //LevelName = ae.LevelName,
  50. //ValidDate = a.ValidDate,
  51. Remark = a.Remark,
  52. //MaxScore = ae.MaxScore.Value
  53. };
  54. return query;
  55. }
  56. }
  57. }