QuestionSettingDAL.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMISOnline.DataLogic.Repositories;
  6. using EMISOnline.ViewModel.ExamView;
  7. using EMISOnline.Entities;
  8. using System.Linq.Expressions;
  9. namespace EMISOnline.DataLogic.ExamSetting
  10. {
  11. public class QuestionSettingDAL
  12. {
  13. public base_question_typeRepository typeRepository { get; set; }
  14. public questionRepository questionRepository { get; set; }
  15. public question_provid_answerRepository answerRepository { get; set; }
  16. public question_libaryRepository libaryRepository { get; set; }
  17. public base_paramRepository paramRepository { get; set; }
  18. /// 获取试题列表
  19. /// </summary>
  20. public IQueryable<ExamQuestionView> GetQuestionList( Expression<Func<test_question, bool>> expWhere)
  21. {
  22. var query = from q in questionRepository.Entities.Where(expWhere)
  23. join lib in libaryRepository.Entities on q.test_question_libary_id equals lib.test_question_libary_id
  24. where q.test_question_ParentId == null
  25. orderby q.test_question_Id descending
  26. select new ExamQuestionView
  27. {
  28. test_question_Id = q.test_question_Id,
  29. content = q.content,
  30. base_question_type_id = q.base_question_type_id,
  31. question_type_name = q.test_base_question_type.Name,
  32. difficulty_degree = q.difficulty_degree,//(from p in context.test_base_param where p.base_param_parent_id == 3 && p.base_param_id == q.difficulty_degree select p.name).Single(),
  33. test_question_libary_id = q.test_question_libary_id,
  34. questione_lib_name = lib.name,
  35. answers = q.answers,
  36. is_vaild = q.is_vaild,
  37. used_count = q.used_count,
  38. created_date = q.created_date
  39. }
  40. ;
  41. return query;
  42. }
  43. /// <summary>
  44. /// 获取所有子类库
  45. /// </summary>
  46. /// <param name="isFill">是否归档,Null查询所有</param>
  47. /// <param name="parentid">类库ID</param>
  48. /// <param name="subList">子类列表</param>
  49. public void GetSubLibary(bool? isFill, decimal parentid, IList<test_question_libary> subList)
  50. {
  51. var query = from lib in libaryRepository.Entities
  52. where lib.parent_id == parentid && (isFill == null || lib.filled == isFill)
  53. select lib;
  54. foreach (var subLib in query.ToList())
  55. {
  56. subList.Add(subLib);
  57. GetSubLibary(isFill, subLib.test_question_libary_id, subList);
  58. }
  59. }
  60. }
  61. }