12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.ViewModel.SupervisionManage;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using EMIS.DataLogic.Repositories;
- using EMIS.ViewModel;
- namespace EMIS.DataLogic.SupervisionManage
- {
- public class SupDocumentDAL
- {
- public SupDocumentRepository supDocumentRepository { get; set; }
- public UserRepository userRepository { get; set; }
- public DocumentAttachmentRepository documentAttachmentRepository { get; set; }
- public IQueryable<SupDocumentView> GetSupDocumentView(Expression<Func<SUP_SupDocument, bool>> exp)
- {
- var query = from sdr in supDocumentRepository.GetList(exp)
- join user in userRepository.Entities
- on sdr.CreateUserID equals user.UserID
- join dar in documentAttachmentRepository.Entities
- on sdr.DocumentID equals dar.DocumentID
- select new SupDocumentView
- {
- DocumentID = sdr.DocumentID,
- Url = dar.Url,
- DocumentTypeID = sdr.DocumentType,
- Title = sdr.Title,
- CreateCollegeID = user.CF_Staff.CollegeID,
- CreateCollegeName = user.CF_Staff.CF_College.Name,
- CreateUserID = sdr.CreateUserID,
- CreateUserName = user.Name,
- CreateTime = sdr.CreateTime
- };
- return query;
- }
- public IQueryable<FileUploadView> GetDocumentAttachmentQueryable(Expression<Func<SUP_SupDocument, bool>> exp)
- {
- var tableName = typeof(SUP_DocumentAttachment).Name;
- var sql = (from record in supDocumentRepository.GetList(exp)
- from attachment in documentAttachmentRepository.Entities.Where(x => x.DocumentID == record.DocumentID)
- select new FileUploadView
- {
- FileID = attachment.DocumeAttachmentID,
- TableName = tableName,
- FormID = attachment.DocumentID,
- FileName = attachment.Name,
- FileUrl = attachment.Url
- });
- return sql;
- }
- }
- }
|