InSchoolSettingDAL.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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.StudentManage.StudentStatistics;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. namespace EMIS.DataLogic.StudentManage.StudentStatistics
  11. {
  12. public class InSchoolSettingDAL
  13. {
  14. public InSchoolSettingRepository InSchoolSettingRepository { get; set; }
  15. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  16. public UserRepository UserRepository { get; set; }
  17. /// <summary>
  18. /// 查询对应的在校状态设定信息View(对应的字典表信息左连设定表)
  19. /// </summary>
  20. /// <param name="expDictionaryItem"></param>
  21. /// <param name="expInSchoolSetting"></param>
  22. /// <returns></returns>
  23. public IQueryable<InSchoolSettingView> GetInSchoolSettingViewQueryable(Expression<Func<Sys_DictionaryItem, bool>> expDictionaryItem,
  24. Expression<Func<CF_InSchoolSetting, bool>> expInSchoolSetting)
  25. {
  26. var query = from dicit in DictionaryItemRepository.GetList(expDictionaryItem)
  27. join set in InSchoolSettingRepository.GetList(expInSchoolSetting)
  28. on dicit.Value equals set.InSchoolStatusID into tempit
  29. from itset in tempit.DefaultIfEmpty()
  30. join usc in UserRepository.Entities
  31. on itset.CreateUserID equals usc.UserID into tempusc
  32. from uscu in tempusc.DefaultIfEmpty()
  33. join usm in UserRepository.Entities
  34. on itset.ModifyUserID equals usm.UserID into tempusm
  35. from usmu in tempusm.DefaultIfEmpty()
  36. select new InSchoolSettingView
  37. {
  38. InSchoolSettingID = itset.InSchoolSettingID == null ? Guid.Empty : itset.InSchoolSettingID,
  39. InSchoolStatusID = dicit.Value,
  40. InSchoolStatusName = dicit.Name,
  41. IsSelected = itset.IsSelected == null ? false : itset.IsSelected,
  42. IsDisplay = dicit.RecordStatus > (int)SYS_STATUS.UNUSABLE ? true : false,
  43. RecordStatus = itset.RecordStatus,
  44. CreateUserID = itset.CreateUserID,
  45. CreateUserName = uscu.Name,
  46. CreateTime = itset.CreateTime,
  47. ModifyUserID = itset.ModifyUserID,
  48. ModifyUserName = usmu.Name,
  49. ModifyTime = itset.ModifyTime
  50. };
  51. return query;
  52. }
  53. /// <summary>
  54. /// 查询对应的在校状态设定信息View(设定表与对应的字典表信息内联)
  55. /// </summary>
  56. /// <param name="exp"></param>
  57. /// <returns></returns>
  58. public IQueryable<InSchoolSettingView> GetInSchoolSettingViewQueryable(Expression<Func<CF_InSchoolSetting, bool>> exp)
  59. {
  60. var query = from set in InSchoolSettingRepository.GetList(exp)
  61. join dicit in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_InschoolStatus).Name)
  62. on set.InSchoolStatusID equals dicit.Value
  63. join usc in UserRepository.Entities
  64. on set.CreateUserID equals usc.UserID into tempusc
  65. from uscu in tempusc.DefaultIfEmpty()
  66. join usm in UserRepository.Entities
  67. on set.ModifyUserID equals usm.UserID into tempusm
  68. from usmu in tempusm.DefaultIfEmpty()
  69. select new InSchoolSettingView
  70. {
  71. InSchoolSettingID = set.InSchoolSettingID,
  72. InSchoolStatusID = dicit.Value,
  73. InSchoolStatusName = dicit.Name,
  74. IsSelected = set.IsSelected == null ? false : set.IsSelected,
  75. IsDisplay = dicit.RecordStatus > (int)SYS_STATUS.UNUSABLE ? true : false,
  76. RecordStatus = set.RecordStatus,
  77. CreateUserID = set.CreateUserID,
  78. CreateUserName = uscu.Name,
  79. CreateTime = set.CreateTime,
  80. ModifyUserID = set.ModifyUserID,
  81. ModifyUserName = usmu.Name,
  82. ModifyTime = set.ModifyTime
  83. };
  84. return query;
  85. }
  86. }
  87. }