EvaluationTargetDAL.cs 4.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using EMIS.Entities;
  7. using EMIS.ViewModel.EvaluationManage.EvaluationTable;
  8. using EMIS.DataLogic.Repositories;
  9. namespace EMIS.DataLogic.EvaluationManage.EvaluationTable
  10. {
  11. public class EvaluationTargetDAL
  12. {
  13. public EvaluationTargetRepository EvaluationTargetRepository { get; set; }
  14. public EvaluationTableRepository EvaluationTableRepository { get; set; }
  15. public EvaluationNormRepository EvaluationNormRepository { get; set; }
  16. public EvaluationParticipateTypeRepository EvaluationParticipateTypeRepository { get; set; }
  17. public EvaluationIntTypeRepository EvaluationIntTypeRepository { get; set; }
  18. public EvaluationProjectRepository EvaluationProjectRepository { get; set; }
  19. public UserRepository UserRepository { get; set; }
  20. /// <summary>
  21. /// 查询对应的评价指标信息EvaluationTargetView
  22. /// </summary>
  23. /// <param name="exp"></param>
  24. /// <returns></returns>
  25. public IQueryable<EvaluationTargetView> GetEvaluationTargetViewQueryable(Expression<Func<EM_EvaluationTarget, bool>> exp)
  26. {
  27. var query = from evtg in EvaluationTargetRepository.GetList(exp)
  28. join evtb in EvaluationTableRepository.Entities
  29. on evtg.EvaluationTableID equals evtb.EvaluationTableID
  30. join evnm in EvaluationNormRepository.Entities
  31. on evtg.EvaluationNormID equals evnm.EvaluationNormID
  32. join evpt in EvaluationParticipateTypeRepository.Entities
  33. on evtb.EvaluationParticipateTypeID equals evpt.EvaluationParticipateTypeID
  34. join evit in EvaluationIntTypeRepository.Entities
  35. on evtb.EvaluationIntTypeID equals evit.EvaluationIntTypeID
  36. join pj in
  37. (
  38. from pj in EvaluationProjectRepository.Entities
  39. group pj by pj.EvaluationTargetID into gpj
  40. select new
  41. {
  42. EvaluationTargetID = gpj.Key,
  43. ProjectCount = gpj.Count()
  44. }
  45. )
  46. on evtg.EvaluationTargetID equals pj.EvaluationTargetID into temppj
  47. from evpj in temppj.DefaultIfEmpty()
  48. join usc in UserRepository.Entities
  49. on evtg.CreateUserID equals usc.UserID into tempusc
  50. from uscu in tempusc.DefaultIfEmpty()
  51. join usm in UserRepository.Entities
  52. on evtg.ModifyUserID equals usm.UserID into tempusm
  53. from usmu in tempusm.DefaultIfEmpty()
  54. select new EvaluationTargetView
  55. {
  56. EvaluationTargetID = evtg.EvaluationTargetID,
  57. OrderNo = evtg.OrderNo,
  58. Code = evtg.Code,
  59. Name = evtg.Name,
  60. EvaluationTableID = evtg.EvaluationTableID,
  61. EvaluationTableCode = evtb.Code,
  62. EvaluationTableName = evtb.Name,
  63. EvaluationTableWeight = evtb.Weight,
  64. EvaluationParticipateTypeID = evtb.EvaluationParticipateTypeID,
  65. ParticipateTypeID = evpt.ParticipateTypeID,
  66. IsStudent = evpt.IsStudent.Value,
  67. EvaluationTypeID = evtb.EvaluationIntTypeID,
  68. EvaluationTypeCode = evit.Code,
  69. EvaluationTypeName = evit.Name,
  70. TeachingModeIDList = evit.EM_EvaluationTeachingMode.OrderBy(x => x.TeachingModeID).Select(x => x.TeachingModeID).ToList(),
  71. EvaluationNormID = evtg.EvaluationNormID,
  72. EvaluationNormName = evnm.Name,
  73. NormTypeID = evnm.NormTypeID,
  74. Weight = evtg.Weight,
  75. ProjectCount = evpj.ProjectCount == null ? 0 : evpj.ProjectCount,
  76. Remark = evtg.Remark,
  77. RecordStatus = evtg.RecordStatus,
  78. CreateUserID = evtg.CreateUserID,
  79. CreateUserName = uscu.Name,
  80. CreateTime = evtg.CreateTime,
  81. ModifyUserID = evtg.ModifyUserID,
  82. ModifyUserName = usmu.Name,
  83. ModifyTime = evtg.ModifyTime
  84. };
  85. return query;
  86. }
  87. }
  88. }