StudentRecordDAL.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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.SystemView;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel.Students;
  10. namespace EMIS.DataLogic.StudentSystem.StudentMaterial
  11. {
  12. public class StudentRecordDAL
  13. {
  14. public StudentRepository StudentRepository { get; set; }
  15. public StudentProfileRepository ProfileRepository { get; set; }
  16. public StudentContactRepository ContactRepository { get; set; }
  17. public RecruitstudentsRepository RecruitsRepository { get; set; }
  18. public ClassmajorRepository ClassRepository { get; set; }
  19. public GrademajorRepository GradeRepository { get; set; }
  20. public FacultymajorRepository FacultyRepository { get; set; }
  21. public CollegeRepository CollegeRepository { get; set; }
  22. public SchoolyearRepository SchoolyearRepository { get; set; }
  23. public StudentRecordView GetStudentByStudentNo(Guid StudentID)
  24. {
  25. var query = from student in StudentRepository.Entities
  26. join profile in ProfileRepository.Entities on student.UserID equals profile.UserID
  27. join contact in ContactRepository.Entities on profile.UserID equals contact.UserID
  28. join recruits in RecruitsRepository.Entities on contact.UserID equals recruits.UserID
  29. join cla in ClassRepository.Entities on student.ClassmajorID equals cla.ClassmajorID
  30. join grade in GradeRepository.Entities on cla.GrademajorID equals grade.GrademajorID
  31. join faculty in FacultyRepository.Entities on grade.FacultymajorID equals faculty.FacultymajorID
  32. join college in CollegeRepository.Entities on faculty.CollegeID equals college.CollegeID
  33. join schoolyear in SchoolyearRepository.Entities
  34. on new { Years = grade.SchoolyearID, grade.SchoolcodeID }
  35. equals new { Years = (int?)schoolyear.Years, SchoolcodeID = (int?)schoolyear.SchoolcodeID } into dschoolyear
  36. from schoolyear in dschoolyear.DefaultIfEmpty()
  37. where student.UserID == StudentID
  38. select new StudentRecordView()
  39. {
  40. IsDreamProject=student.IsDreamProject==true,
  41. Career=student.Career,
  42. CardNo=student.CF_StudentAccount.CardNo,
  43. BankName=student.CF_StudentAccount.BankName,
  44. UserID = student.UserID,
  45. LoginID = student.Sys_User.LoginID,
  46. StudentNo = student.StudentCardNo,
  47. UserName = student.Sys_User.Name,
  48. PhotoUrl = student.PhotoUrl,
  49. UsedName = profile.UsedName,
  50. Sex = student.Sex.Value,
  51. BirthDate = profile.BirthDate,
  52. Nation = profile.Nation,
  53. Politics = profile.Politics,
  54. CertificatesType = student.CertificatesType,
  55. IDNumber = student.IDNumber,
  56. CultureModel = student.CultureModel,
  57. StudentType = student.StudentType,
  58. InSchoolStatusID=student.InSchoolStatusID,
  59. StudentStatus = student.StudentStatus,
  60. EntranceDate = recruits.EntranceDate,
  61. EntranceWay = recruits.EntranceWay,
  62. ExamineeNum = recruits.ExamineeNum,
  63. ExamineeType = recruits.ExamineeType,
  64. Features = recruits.Features,
  65. CollegeName = college.Name,
  66. Score = recruits.Score,
  67. Territorial = recruits.Territorial,
  68. Area = student.CF_Recruitstudents.Area,
  69. Place = profile.Place,
  70. BornPlace =student.CF_Recruitstudents.PlaceBirth,
  71. Healthy = profile.Healthy,
  72. Specialty = profile.Specialty,
  73. Height = profile.Height,
  74. Weight = profile.Weight,
  75. Email = contact.Email,
  76. QQ = contact.QQ,
  77. Dormitory = contact.Dormitory,
  78. Telephone = contact.Telephone,
  79. Mobile = contact.Mobile,
  80. HomeAddress = contact.HomeAddress,
  81. WorkUnit = contact.WorkUnit,
  82. Zipcode = contact.Zipcode,
  83. Recipient = contact.Recipient,
  84. PlanningGraduateDate = student.PlanningGraduateDate,
  85. GradeName = grade.Name,
  86. GradeCode = grade.Code,
  87. StandardID = grade.CF_Facultymajor.StandardID,
  88. ClassID=cla.ClassmajorID,
  89. ClassName = cla.Name,
  90. LearnSystem = faculty.LearnSystem,
  91. No = cla.No,
  92. EducationID = faculty.EducationID,
  93. LearningformID = faculty.LearningformID,
  94. LearningstyleID = faculty.LearningstyleID,
  95. Remarks = profile.Remarks,
  96. FacultymajorID = grade.FacultymajorID,
  97. StartSchoolcodeID = grade.SchoolcodeID,
  98. StartSchoolyearValue = schoolyear.Value
  99. };
  100. return query.SingleOrDefault();
  101. }
  102. }
  103. }