SOCDetailDAL.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. using Bowin.Common.Linq;
  11. namespace EMIS.DataLogic.DQPSystem
  12. {
  13. public class SOCDetailDAL
  14. {
  15. public SOCRepository SOCRepository { get; set; }
  16. public SOCDetailRepository SOCDetailRepository { get; set; }
  17. public SOCDetailAttachmentRepository SOCDetailAttachmentRepository { get; set; }
  18. public SOCTemplateRepository SOCTemplateRepository { get; set; }
  19. public SchoolyearRepository schoolyearRepository { get; set; }
  20. public CoursematerialRepository coursematerialRepository { get; set; }
  21. public EducationMissionRepository educationMissionRepository { get; set; }
  22. public EducationMissionClassRepository educationMissionClassRepository { get; set; }
  23. public SOCDetailStudentRepository SOCDetailStudentRepository { get; set; }
  24. public SOCDetailStudentScoreRepository SOCDetailStudentScoreRepository { get; set; }
  25. public IQueryable<SOCDetailView> GetSOCDetailViewQueryable(Expression<Func<DQP_SOCDetail, bool>> exp)
  26. {
  27. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  28. //exp = exp.And(x => x.CreateUserID == curUser.UserID);
  29. var query = from detail in SOCDetailRepository.GetList(exp)
  30. join edu in educationMissionRepository.Entities
  31. on detail.DQP_SOC.EducationMissionID equals edu.EducationMissionID
  32. into dedu
  33. from edu in dedu.DefaultIfEmpty()
  34. select new SOCDetailView
  35. {
  36. SOCDetailID = detail.SOCDetailID,
  37. EducationMissionID = detail.DQP_SOC.EducationMissionID,
  38. EducationMissionName = edu.ClassName,
  39. SOCID = detail.SOCID,
  40. DepartmentID = detail.DQP_SOC.DepartmentID,
  41. SchoolyearID = detail.DQP_SOC.SchoolyearID,
  42. SchoolyearCode = detail.DQP_SOC.CF_Schoolyear.Code,
  43. CoursematerialID = detail.DQP_SOC.CoursematerialID,
  44. CourseCode = detail.DQP_SOC.EM_Coursematerial.CourseCode,
  45. CourseName = detail.DQP_SOC.EM_Coursematerial.CourseName,
  46. Name = detail.Name,
  47. Weight = detail.Weight,
  48. Credit = detail.Credit,
  49. Description = detail.Description,
  50. IsGroup = detail.IsGroup,
  51. IsGroupin = detail.IsGroup.Value,
  52. StartTime = detail.StartTime,
  53. EndTime = detail.EndTime,
  54. Attachment = detail.DQP_SOCDetailAttachment,
  55. GroupCount = detail.DQP_SOCDetailGroup.Count(),
  56. StudentCount = detail.DQP_SOC.CF_Student.Count,
  57. };
  58. return query;
  59. }
  60. public IOrderedQueryable<FileUploadView> GetSOCDetailAttachmentView(Expression<Func<DQP_SOCDetail, bool>> exp)
  61. {
  62. var tableName = typeof(DQP_SOCDetailAttachment).Name;
  63. var sql = (from @group in SOCDetailRepository.GetList(exp)
  64. from attachment in @group.DQP_SOCDetailAttachment
  65. orderby attachment.CreateTime descending
  66. select new FileUploadView
  67. {
  68. FileID = attachment.SOCDetailAttachmentID,
  69. FileName = attachment.Name,
  70. FileUrl = attachment.Url,
  71. FormID = attachment.SOCDetailID,
  72. TableName = tableName
  73. });
  74. return (IOrderedQueryable<FileUploadView>)sql;
  75. }
  76. }
  77. }