CoursesTimeDAL.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using System.Linq.Expressions;
  7. using EMIS.Entities;
  8. using EMIS.ViewModel.CalendarManage;
  9. using EMIS.ViewModel;
  10. namespace EMIS.DataLogic.Common.CalendarManage
  11. {
  12. public class CoursesTimeDAL
  13. {
  14. public CoursesTimeRepository coursesTimeRepository { get; set; }
  15. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  16. /// <summary>
  17. /// 读取课程时间信息
  18. /// </summary>
  19. /// <param name="exp"></param>
  20. /// <returns></returns>
  21. public IQueryable<CoursesTimeView> GetCoursesTimeQueryable(Expression<Func<EM_CoursesTime, bool>> exp)
  22. {
  23. var query = from a in coursesTimeRepository.GetList(exp)
  24. join c in dictionaryItemRepository.Entities on new { a.TimesSegment, DictionaryCode = "CF_TimesSegment" }
  25. equals new { TimesSegment = c.Value.Value, c.DictionaryCode } into gbsta
  26. from gicbsta in gbsta.DefaultIfEmpty()
  27. select new CoursesTimeView
  28. {
  29. CoursesTimeID = a.CoursesTimeID,
  30. StartTimes = a.StartTimes,
  31. EndTimes = a.EndTimes,
  32. TimesSegment = a.TimesSegment,
  33. TimesSegmentName = gicbsta.Name,
  34. StartHour = a.StartHour,
  35. StartMinutes = a.StartMinutes,
  36. EndHour = a.EndHour,
  37. EndMinutes = a.EndMinutes,
  38. CreateUserID = a.CreateUserID,
  39. CreateTime = a.CreateTime,
  40. ModifyUserID = a.ModifyUserID,
  41. ModifyTime = a.ModifyTime
  42. };
  43. return query;
  44. }
  45. public IQueryable<CoursesTimeView> GetNextCoursesTimeQueryable(Expression<Func<EM_CoursesTime, bool>> exp)
  46. {
  47. var query = from a in coursesTimeRepository.GetList(exp)
  48. join nc in coursesTimeRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE) on a.StartTimes + 1 equals nc.StartTimes
  49. join c in dictionaryItemRepository.Entities on new { nc.TimesSegment, DictionaryCode = "CF_TimesSegment" }
  50. equals new { TimesSegment = c.Value.Value, c.DictionaryCode } into gbsta
  51. from gicbsta in gbsta.DefaultIfEmpty()
  52. select new CoursesTimeView
  53. {
  54. CoursesTimeID = nc.CoursesTimeID,
  55. StartTimes = a.StartTimes,
  56. EndTimes = a.EndTimes,
  57. TimesSegment = nc.TimesSegment,
  58. TimesSegmentName = gicbsta.Name,
  59. StartHour = nc.StartHour,
  60. StartMinutes = nc.StartMinutes,
  61. EndHour = nc.EndHour,
  62. EndMinutes = nc.EndMinutes,
  63. CreateUserID = nc.CreateUserID,
  64. CreateTime = nc.CreateTime,
  65. ModifyUserID = nc.ModifyUserID,
  66. ModifyTime = nc.ModifyTime
  67. };
  68. return query;
  69. }
  70. }
  71. }