SchoolYearDAL.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using System.Linq.Expressions;
  7. using EMIS.Entities;
  8. using EMIS.ViewModel.CalendarManage;
  9. using Bowin.Common.DataTime;
  10. namespace EMIS.DataLogic.Common.CalendarManage
  11. {
  12. public class SchoolYearDAL
  13. {
  14. public SchoolyearRepository schoolyearRepository { get; set; }
  15. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  16. /// <summary>
  17. /// 读取学年学期信息
  18. /// </summary>
  19. /// <param name="exp"></param>
  20. /// <returns></returns>
  21. public IQueryable<SchoolYearView> GetSchoolYearQueryable(Expression<Func<CF_Schoolyear, bool>> exp)
  22. {
  23. var query = from a in schoolyearRepository.GetList(exp)
  24. join c in dictionaryItemRepository.Entities on new { a.SchoolcodeID, DictionaryCode = "CF_Semester" }
  25. equals new { SchoolcodeID = c.Value.Value, c.DictionaryCode } into gbsta
  26. from gicbsta in gbsta.DefaultIfEmpty()
  27. select new SchoolYearView
  28. {
  29. SchoolYearID = a.SchoolyearID,
  30. Code = a.Code,
  31. Years = a.Years,
  32. SchoolcodeID = a.SchoolcodeID,
  33. SchoolcodeName = gicbsta.Name,
  34. FullName = a.Years.ToString() + "学年" + gicbsta.Name,
  35. WeeksNum = a.WeeksNum,
  36. FirstWeek = (DateTime)a.FirstWeek,
  37. IsCurrent = a.IsCurrent,
  38. Current = a.IsCurrent == true ? "是" : "否",
  39. WeekDays = a.WeekDays,
  40. CreateUserID = a.CreateUserID,
  41. CreateTime = a.CreateTime,
  42. Value = a.Value
  43. };
  44. return query;
  45. }
  46. public IQueryable<SchoolYearView> GetYearsQueryable(Expression<Func<CF_Schoolyear, bool>> exp)
  47. {
  48. var query = from a in schoolyearRepository.GetList(exp).Distinct()
  49. select new SchoolYearView
  50. {
  51. Years = a.Years,
  52. };
  53. return query;
  54. }
  55. }
  56. }