ScoreParameterSettingDAL.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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.ScoreManage;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. namespace EMIS.DataLogic.ScoreManage
  11. {
  12. public class ScoreParameterSettingDAL
  13. {
  14. public ScoreParameterSettingRepository ScoreParameterSettingRepository { get; set; }
  15. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  16. public IQueryable<ER_ScoreParameterSetting> GetScoreParameterSettingViewQueryable(Expression<Func<ER_ScoreParameterSetting, bool>> exp)
  17. {
  18. var query = from a in ScoreParameterSettingRepository.GetList(exp)
  19. select a;
  20. return query;
  21. }
  22. public IQueryable<ScoreParameterSettingView> GetScoreParameterSettingViewQueryable()
  23. {
  24. var sql = (from detail in ScoreParameterSettingRepository.Entities
  25. where detail.ExamsTypeID == null && detail.CourseTypeID == null
  26. select new ScoreParameterSettingView
  27. {
  28. ExamsTypeID = null,
  29. ExamsTypeName = null,
  30. CourseTypeID = null,
  31. CourseTypeName = null,
  32. ScoreFormulaID = detail.ScoreFormulaID,
  33. IsTotalFormula = detail.IsTotalFormula ?? false,
  34. CreditFormulaID = detail.CreditFormulaID,
  35. IsCreditFormula = detail.IsCreditFormula ?? false,
  36. GradePointFormulaID = detail.GradePointFormulaID,
  37. IsGradePointFormula = detail.IsGradePointFormula ?? false,
  38. OrderNo = (detail.ExamsTypeID ?? 0) * (detail.CourseTypeID ?? 0)
  39. }).Concat(
  40. from category in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_ExamsCategory.ToString())
  41. join detail in ScoreParameterSettingRepository.Entities
  42. on new { ExamsTypeID = category.Value, CourseTypeID = (int?)null }
  43. equals new { detail.ExamsTypeID, detail.CourseTypeID } into ddetail
  44. from detail in ddetail.DefaultIfEmpty()
  45. select new ScoreParameterSettingView
  46. {
  47. ExamsTypeID = category.Value,
  48. ExamsTypeName = category.Name,
  49. CourseTypeID = null,
  50. CourseTypeName = null,
  51. ScoreFormulaID = detail.ScoreFormulaID,
  52. IsTotalFormula = detail.IsTotalFormula ?? false,
  53. CreditFormulaID = detail.CreditFormulaID,
  54. IsCreditFormula = detail.IsCreditFormula ?? false,
  55. GradePointFormulaID = detail.GradePointFormulaID,
  56. IsGradePointFormula = detail.IsGradePointFormula ?? false,
  57. OrderNo = (detail.ExamsTypeID ?? 0) * (detail.CourseTypeID ?? 0)
  58. }
  59. ).Concat(
  60. from courseType in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_CourseType.ToString())
  61. join detail in ScoreParameterSettingRepository.Entities
  62. on new { ExamsTypeID = (int?)null, CourseTypeID = courseType.Value }
  63. equals new { detail.ExamsTypeID, detail.CourseTypeID } into ddetail
  64. from detail in ddetail.DefaultIfEmpty()
  65. select new ScoreParameterSettingView
  66. {
  67. ExamsTypeID = null,
  68. ExamsTypeName = null,
  69. CourseTypeID = courseType.Value,
  70. CourseTypeName = courseType.Name,
  71. ScoreFormulaID = detail.ScoreFormulaID,
  72. IsTotalFormula = detail.IsTotalFormula ?? false,
  73. CreditFormulaID = detail.CreditFormulaID,
  74. IsCreditFormula = detail.IsCreditFormula ?? false,
  75. GradePointFormulaID = detail.GradePointFormulaID,
  76. IsGradePointFormula = detail.IsGradePointFormula ?? false,
  77. OrderNo = (detail.ExamsTypeID ?? 0) * (detail.CourseTypeID ?? 0)
  78. }
  79. ).Concat(
  80. from category in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_ExamsCategory.ToString())
  81. join courseType in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_CourseType.ToString())
  82. on true equals true
  83. join detail in ScoreParameterSettingRepository.Entities
  84. on new { ExamsTypeID = category.Value, CourseTypeID = courseType.Value }
  85. equals new { detail.ExamsTypeID, detail.CourseTypeID } into ddetail
  86. from detail in ddetail.DefaultIfEmpty()
  87. select new ScoreParameterSettingView
  88. {
  89. ExamsTypeID = category.Value,
  90. ExamsTypeName = category.Name,
  91. CourseTypeID = courseType.Value,
  92. CourseTypeName = courseType.Name,
  93. ScoreFormulaID = detail.ScoreFormulaID,
  94. IsTotalFormula = detail.IsTotalFormula ?? false,
  95. CreditFormulaID = detail.CreditFormulaID,
  96. IsCreditFormula = detail.IsCreditFormula ?? false,
  97. GradePointFormulaID = detail.GradePointFormulaID,
  98. IsGradePointFormula = detail.IsGradePointFormula ?? false,
  99. OrderNo = (detail.ExamsTypeID ?? 0) * (detail.CourseTypeID ?? 0)
  100. });
  101. return sql;
  102. }
  103. }
  104. }