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 GetSupDocumentView(Expression> 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 GetDocumentAttachmentQueryable(Expression> 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; } } }