BatchRepeatDAL.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.ViewModel.DifferentDynamic;
  6. using System.Linq.Expressions;
  7. using EMIS.Entities;
  8. namespace EMIS.DataLogic.Common.Students
  9. {
  10. public class BatchRepeatDAL : DifferentDynamicDAL
  11. {
  12. public IQueryable<DifferentDynamicView> GetBatchRepeatProcessView(Expression<Func<CF_DifferentDynamic, bool>> exp)
  13. {
  14. var query = (from change in DifferentDynamicRepository.GetList(exp)
  15. join user in UserRepository.Entities on change.UserID equals user.UserID
  16. join classmajor in ClassmajorRepository.Entities on change.BeforeClassmajorID equals classmajor.ClassmajorID
  17. join grade in GrademajorRepository.Entities on classmajor.GrademajorID equals grade.GrademajorID
  18. join afterGrade in GrademajorRepository.Entities
  19. on new { grade.FacultymajorID, SchoolyearID = grade.GradeID + 1 }
  20. equals new { afterGrade.FacultymajorID, SchoolyearID = afterGrade.GradeID } into dafterGrade
  21. from afterGrade in dafterGrade.DefaultIfEmpty()
  22. join afterClass in ClassmajorRepository.Entities
  23. on new { GrademajorID = (Guid?)afterGrade.GrademajorID, classmajor.ClassNum }
  24. equals new { afterClass.GrademajorID, afterClass.ClassNum } into dafterClass
  25. from afterClass in dafterClass.DefaultIfEmpty()
  26. join afterClass1 in ClassmajorRepository.Entities
  27. on afterGrade.GrademajorID equals afterClass1.GrademajorID into dafterClass1
  28. from afterClass1 in dafterClass1.DefaultIfEmpty()
  29. group new { Change = change, AfterClass = afterClass, AfterClass1 = afterClass1 }
  30. by new { Change = change, User = user } into g
  31. select new DifferentDynamicView
  32. {
  33. EntityID = g.Key.Change.StudentChangeID,
  34. SchoolyearID = g.Key.Change.SchoolyearID,
  35. UserID = g.Key.Change.UserID,
  36. Name = g.Key.User.Name,
  37. DifferentDynamicType = g.Key.Change.ChangeTypeID,
  38. Reason = g.Key.Change.ChangeReasonID,
  39. InSchoolStatusID = g.Key.Change.BeforeInSchoolStatusID,
  40. StudentStatus = g.Key.Change.BeforeStudentStatus,
  41. //StandardID = g.Key.Change.StandardID,
  42. ClassmajorID = g.Key.Change.BeforeClassmajorID,
  43. //AfterStandardID = g.Key.Change.StandardID,
  44. AfterClassmajorID = g.Select(x => (Guid?)x.AfterClass.ClassmajorID).FirstOrDefault() ?? g.Select(x => (Guid?)x.AfterClass1.ClassmajorID).FirstOrDefault(),
  45. AfterInSchoolStatusID = g.Key.Change.AfterInSchoolStatusID,
  46. AfterStudentStatus = g.Key.Change.AfterStudentStatus,
  47. ReturnSchoolyearID = g.Key.Change.ReturnSchoolyearID,
  48. ApplyTypeID = g.Key.Change.ChangeApplyTypeID,
  49. ApplyRemark = g.Key.Change.Description,
  50. BeginTime = g.Key.Change.ChangeDate,
  51. EndTime = g.Key.Change.ChangeDate,
  52. //Source = g.Key.Change.Source,
  53. //Direction = g.Key.Change.Direction,
  54. EntityApprovalStatus = g.Key.Change.ApprovalStatus,
  55. Remark = g.Key.Change.Remark,
  56. EntityCreateTime = g.Key.Change.CreateTime,
  57. EntityApplyDate = g.Key.Change.ChangeDate,
  58. EntityCreateUserID = g.Key.Change.CreateUserID,
  59. }
  60. );
  61. return query;
  62. }
  63. }
  64. }