ActivitieDAL.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 ActivitieDAL
  12. {
  13. public ActivitiesSetsRepository activitiesSetsRepository { get; set; }
  14. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  15. /// <summary>
  16. /// 读取固定活动信息
  17. /// </summary>
  18. /// <param name="exp"></param>
  19. /// <returns></returns>
  20. public IQueryable<ActivitieView> GetActivitiesQueryable(Expression<Func<CF_ActivitiesSets, bool>> exp)
  21. {
  22. var query = from a in activitiesSetsRepository.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 ActivitieView
  30. {
  31. ActivitiesID = a.ActivitiesID,
  32. Name = a.Name,
  33. ActivitiesTime = a.ActivitiesTimeMonth+"-"+a.ActivitiesTimeDay,
  34. ActivitiesTimeMonth=a.ActivitiesTimeMonth,
  35. ActivitiesTimeDay=a.ActivitiesTimeDay,
  36. TimesSegment = a.TimesSegment,
  37. TimesSegmentName = gicbsta.Name,
  38. ActivitiesContent = a.ActivitiesContent,
  39. ActivitiesType = a.ActivitiesType,
  40. ActivitiesTypeName = gicbty.Name,
  41. CreateUserID = a.CreateUserID,
  42. CreateTime = a.CreateTime
  43. };
  44. return query;
  45. }
  46. }
  47. }