ShareRecordDAL.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using EMIS.DataLogic.Repositories;
  2. using EMIS.Entities;
  3. using EMIS.ViewModel.ProjectShareManage;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Linq.Expressions;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace EMIS.DataLogic.ProjectShareManage
  11. {
  12. public class ShareRecordDAL
  13. {
  14. public ShareRecordRepository shareRecordRepository { get; set; }
  15. public AnnouncementRepository announcementRepository { get; set; }
  16. public UserRepository userRepository { get; set; }
  17. public ClassmajorRepository classmajorRepository { get; set; }
  18. public StudentRepository studentRepository { get; set; }
  19. public WechatSubscribeRepository wechatSubscribeRepository { get; set; }
  20. public IQueryable<ShareRecordView> GetShareRecordView(Expression<Func<Sys_ShareRecord, bool>> shareExp)
  21. {
  22. var query = from sr in shareRecordRepository.GetList(shareExp)
  23. from ann in announcementRepository.Entities.Where(x => x.AnnouncementID == sr.AnnouncementID)
  24. from user in userRepository.Entities.Where(x => x.UserID == sr.UserID)
  25. from stu in studentRepository.Entities.Where(x => x.UserID == user.UserID)
  26. from cla in classmajorRepository.Entities.Where(x => x.ClassmajorID == stu.ClassmajorID).DefaultIfEmpty()
  27. select new ShareRecordView
  28. {
  29. ShareRecordID = sr.ShareRecordID,
  30. DateTime = sr.DateTime,
  31. AnnouncementID = sr.AnnouncementID,
  32. Title = ann.Title,
  33. UserID = sr.UserID,
  34. OpenID = sr.OpenID,
  35. UserName = user.Name,
  36. ClassmajorID = cla.ClassmajorID,
  37. ClassmajorName = cla.Name,
  38. Count = 1,
  39. RecordStatus = sr.RecordStatus,
  40. CreateUserID = sr.CreateUserID,
  41. CreateTime = sr.CreateTime,
  42. ModifyUserID = sr.ModifyUserID,
  43. ModifyTime = sr.ModifyTime
  44. };
  45. return query;
  46. }
  47. }
  48. }