SOCDocDAL.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 EMIS.ViewModel.DQPSystem;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. namespace EMIS.DataLogic.DQPSystem
  11. {
  12. public class SOCDocDAL
  13. {
  14. public DocumentRepository DocumentRepository { get; set; }
  15. public StaffRepository StaffRepository { get; set; }
  16. public UserRepository UserRepository { get; set; }
  17. public CollegeRepository CollegeRepository { get; set; }
  18. public IQueryable<SOCDocView> GetSOCDocViewQueryable(Expression<Func<DQP_Document, bool>> exp,
  19. Expression<Func<CF_Staff, bool>> staffExp)
  20. {
  21. var sql = (from doc in DocumentRepository.GetList(exp)
  22. from staff in StaffRepository.Entities.Where(staffExp).Where(x => x.UserID == doc.CreateUserID).DefaultIfEmpty()
  23. from user in UserRepository.Entities.Where(x => x.UserID == doc.CreateUserID).DefaultIfEmpty()
  24. from college in CollegeRepository.Entities.Where(x => x.CollegeID == staff.CollegeID).DefaultIfEmpty()
  25. select new SOCDocView
  26. {
  27. DocumentID = doc.DocumentID,
  28. SOCDocTypeID = doc.SOCDocTypeID,
  29. Title = doc.Title,
  30. Content = doc.Content,
  31. RoleList = doc.Sys_Role,
  32. CollegeList = doc.CF_College,
  33. DepartmentList=doc.CF_Department,
  34. RecordStatus = doc.RecordStatus,
  35. IsShow = doc.RecordStatus == (int)CF_GeneralPurpose.IsYes,
  36. CreateCollegeID = staff.CollegeID,
  37. CreateCollegeName = college.Name,
  38. CreateUserID = doc.CreateUserID,
  39. CreateUserName = user.Name,
  40. CreateTime = doc.CreateTime
  41. });
  42. return sql;
  43. }
  44. }
  45. }