OpenControlDAL.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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.ExaminationApply;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. namespace EMIS.DataLogic.ExaminationApply
  11. {
  12. public class OpenControlDAL
  13. {
  14. public ExaminationOpenControlRepository ExaminationOpenControlRepository { get; set; }
  15. public ExaminationSubjectRepository ExaminationSubjectRepository { get; set; }
  16. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  17. public IQueryable<OpenControlView> GetOpenControlView(Expression<Func<EX_ExaminationOpenControl, bool>> openControlExpression)
  18. {
  19. var q = (from oc in ExaminationOpenControlRepository.GetList(openControlExpression)
  20. select new OpenControlView
  21. {
  22. ExaminationSubjectEditID = oc.ExaminationSubjectID,
  23. ExaminationOpenControlID = oc.ExaminationOpenControlID,
  24. ExaminationTypeID = oc.EX_ExaminationSubject.ExaminationTypeID,
  25. ExaminationTypeName = oc.EX_ExaminationSubject.EX_ExaminationType.Name,
  26. ExaminationSubjectID = oc.ExaminationSubjectID,
  27. ExaminationSubjectName = oc.EX_ExaminationSubject.Name,
  28. SchoolyearNumID = oc.SchoolyearNumID,
  29. StudentType = oc.StudentType,
  30. StartDate = oc.StartDate,
  31. EndDate = oc.EndDate,
  32. PeopleNumLimit = oc.PeopleNumLimit,
  33. RecordStatus = oc.RecordStatus,
  34. CreateUserID = oc.CreateUserID,
  35. CreateTime = oc.CreateTime,
  36. ModifyUserID = oc.ModifyUserID,
  37. ModifyTime = oc.ModifyTime
  38. }).OrderBy(x => x.ExaminationTypeName).ThenBy(x => x.ExaminationSubjectName).ThenBy(x => x.StudentType).ThenByDescending(x => x.SchoolyearNumID);
  39. return q;
  40. }
  41. /// <summary>
  42. /// 根据开课控制学生类别
  43. /// </summary>
  44. /// <param name="openControlID"></param>
  45. /// <returns></returns>
  46. public List<string> GetStudentTypeQueryble(Guid? openControlID)
  47. {
  48. var query = from a in ExaminationOpenControlRepository.Entities.Where(x => x.ExaminationOpenControlID == openControlID)
  49. join b in dictionaryItemRepository.Entities on new { a.StudentType, DictionaryCode = DictionaryItem.CF_STUDENTTYPE.ToString() }
  50. equals new { StudentType = b.Value, b.DictionaryCode }
  51. select b.Value.Value.ToString();
  52. return query.ToList();
  53. }
  54. }
  55. }