CourseDAL.cs 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMISOnline.Entities;
  6. using System.Linq.Expressions;
  7. using EMISOnline.DataLogic.Repositories;
  8. using EMISOnline.ViewModel.Educational;
  9. using EMISOnline.ViewModel;
  10. namespace EMISOnline.DataLogic.Educational
  11. {
  12. public class CourseDAL
  13. {
  14. public CoursematerialRepository CoursematerialRepository { get; set; }
  15. public ExecutablePlanRepository ExecutablePlanRepository { get; set; }
  16. public ExecutablePlanTeachingSettingRepository ExecutablePlanTeachingSettingRepository { get; set; }
  17. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  18. public IQueryable<CoursematerView> GetCourseList()
  19. {
  20. var query = from com in CoursematerialRepository.Entities
  21. //join exp in ExecutablePlanRepository.Entities on com.CoursematerialID equals exp.CoursematerialID into expResult
  22. //from expr in expResult.DefaultIfEmpty()
  23. //join expSet in ExecutablePlanTeachingSettingRepository.Entities on expr.ExecutablePlanID equals expSet.ExecutablePlanID into expSetResult
  24. //from expSetr in expSetResult.DefaultIfEmpty()
  25. //join dic in DictionaryItemRepository.Entities.Where(d => d.DictionaryCode == (typeof(CF_CourseQuality).Name)) on expr.CourseQualityID equals dic.Value into dicItem
  26. //from di in dicItem.DefaultIfEmpty()
  27. select new CoursematerView
  28. {
  29. CoursematerialID = com.CoursematerialID,
  30. CourseCode=com.CourseCode,
  31. CourseName = com.CourseName,
  32. //CourseQualityID = expr.CourseQualityID,
  33. //CourseQualityName = di.Name,
  34. //Credit = expSetr.Credit,
  35. //Hours = expSetr.TheoryCourse ?? 0 + expSetr.Practicehours ?? 0 + expSetr.Trialhours ?? 0,
  36. CreateTime = com.CreateTime
  37. };
  38. return query;
  39. }
  40. /// <summary>
  41. /// 获取课程信息
  42. /// </summary>
  43. /// <returns></returns>
  44. public IQueryable<CoursematerView> GetCoursematerialViewQueryable()
  45. {
  46. var query = from a in CoursematerialRepository.Entities
  47. select new CoursematerView
  48. {
  49. CoursematerialID = a.CoursematerialID,
  50. ClassGroupingID = a.ClassGroupingID,
  51. CourseCode = a.CourseCode,
  52. CourseName = a.CourseName,
  53. Abbreviation = a.Abbreviation,
  54. EnglishName = a.EnglishName,
  55. StandardName = a.StandardName,
  56. CourseEdition = a.CourseEdition,
  57. CourseSynopsis = a.CourseSynopsis,
  58. CourseReserve = a.CourseReserve,
  59. IsEnable = a.IsEnable ?? true,
  60. IsEnableName = a.IsEnable == true ? "是" : "否",
  61. CourseLevelID = a.CourseLevelID,
  62. CourseScienceID = a.CourseScienceID,
  63. CreateUserID = a.CreateUserID,
  64. CreateTime = a.CreateTime,
  65. Remarks = a.Remarks
  66. };
  67. return query;
  68. }
  69. }
  70. }