SupDocumentDAL.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.ViewModel.SupervisionManage;
  6. using System.Linq.Expressions;
  7. using EMIS.Entities;
  8. using EMIS.DataLogic.Repositories;
  9. using EMIS.ViewModel;
  10. namespace EMIS.DataLogic.SupervisionManage
  11. {
  12. public class SupDocumentDAL
  13. {
  14. public SupDocumentRepository supDocumentRepository { get; set; }
  15. public UserRepository userRepository { get; set; }
  16. public DocumentAttachmentRepository documentAttachmentRepository { get; set; }
  17. public IQueryable<SupDocumentView> GetSupDocumentView(Expression<Func<SUP_SupDocument, bool>> exp)
  18. {
  19. var query = from sdr in supDocumentRepository.GetList(exp)
  20. join user in userRepository.Entities
  21. on sdr.CreateUserID equals user.UserID
  22. join dar in documentAttachmentRepository.Entities
  23. on sdr.DocumentID equals dar.DocumentID
  24. select new SupDocumentView
  25. {
  26. DocumentID = sdr.DocumentID,
  27. Url = dar.Url,
  28. DocumentTypeID = sdr.DocumentType,
  29. Title = sdr.Title,
  30. CreateCollegeID = user.CF_Staff.CollegeID,
  31. CreateCollegeName = user.CF_Staff.CF_College.Name,
  32. CreateUserID = sdr.CreateUserID,
  33. CreateUserName = user.Name,
  34. CreateTime = sdr.CreateTime
  35. };
  36. return query;
  37. }
  38. public IQueryable<FileUploadView> GetDocumentAttachmentQueryable(Expression<Func<SUP_SupDocument, bool>> exp)
  39. {
  40. var tableName = typeof(SUP_DocumentAttachment).Name;
  41. var sql = (from record in supDocumentRepository.GetList(exp)
  42. from attachment in documentAttachmentRepository.Entities.Where(x => x.DocumentID == record.DocumentID)
  43. select new FileUploadView
  44. {
  45. FileID = attachment.DocumeAttachmentID,
  46. TableName = tableName,
  47. FormID = attachment.DocumentID,
  48. FileName = attachment.Name,
  49. FileUrl = attachment.Url
  50. });
  51. return sql;
  52. }
  53. }
  54. }