SCalendarDAL.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. namespace EMIS.DataLogic.Common.CalendarManage
  10. {
  11. public class SCalendarDAL
  12. {
  13. public SCalendarRepository scalendarRepository { get; set; }
  14. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  15. /// <summary>
  16. /// 读取校历信息
  17. /// </summary>
  18. /// <param name="exp"></param>
  19. /// <returns></returns>
  20. public IQueryable<SCalendarView> GetSCalendarQueryable(Expression<Func<CF_SCalendar, bool>> exp)
  21. {
  22. var query = from a in scalendarRepository.GetList(exp)
  23. join b in dictionaryItemRepository.Entities on new { a.ActivitiesType, DictionaryCode = "CF_ActivitiesType" }
  24. equals new { ActivitiesType = b.Value, b.DictionaryCode } into gbty
  25. from gicbty in gbty.DefaultIfEmpty()
  26. join c in dictionaryItemRepository.Entities on new { a.TimesSegment, DictionaryCode = "CF_TimesSegment" }
  27. equals new { TimesSegment = c.Value.Value, c.DictionaryCode } into gbsta
  28. from gicbsta in gbsta.DefaultIfEmpty()
  29. select new SCalendarView
  30. {
  31. ActivitiesID = a.ActivitiesID,
  32. Name = a.Name,
  33. ActivitiesTime = a.ActivitiesTime,
  34. TimesSegment = a.TimesSegment,
  35. TimesSegmentName = gicbsta.Name,
  36. ActivitiesContent = a.ActivitiesContent,
  37. ActivitiesType = a.ActivitiesType,
  38. ActivitiesTypeName = gicbty.Name,
  39. CreateUserID = a.CreateUserID,
  40. CreateTime = a.CreateTime
  41. };
  42. return query;
  43. }
  44. }
  45. }