using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMISOnline.DataLogic.Repositories; using EMISOnline.ViewModel.ExamView; using EMISOnline.Entities; using System.Linq.Expressions; namespace EMISOnline.DataLogic.ExamSetting { public class QuestionSettingDAL { public base_question_typeRepository typeRepository { get; set; } public questionRepository questionRepository { get; set; } public question_provid_answerRepository answerRepository { get; set; } public question_libaryRepository libaryRepository { get; set; } public base_paramRepository paramRepository { get; set; } /// 获取试题列表 /// public IQueryable GetQuestionList( Expression> expWhere) { var query = from q in questionRepository.Entities.Where(expWhere) join lib in libaryRepository.Entities on q.test_question_libary_id equals lib.test_question_libary_id where q.test_question_ParentId == null orderby q.test_question_Id descending select new ExamQuestionView { test_question_Id = q.test_question_Id, content = q.content, base_question_type_id = q.base_question_type_id, question_type_name = q.test_base_question_type.Name, 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(), test_question_libary_id = q.test_question_libary_id, questione_lib_name = lib.name, answers = q.answers, is_vaild = q.is_vaild, used_count = q.used_count, created_date = q.created_date } ; return query; } /// /// 获取所有子类库 /// /// 是否归档,Null查询所有 /// 类库ID /// 子类列表 public void GetSubLibary(bool? isFill, decimal parentid, IList subList) { var query = from lib in libaryRepository.Entities where lib.parent_id == parentid && (isFill == null || lib.filled == isFill) select lib; foreach (var subLib in query.ToList()) { subList.Add(subLib); GetSubLibary(isFill, subLib.test_question_libary_id, subList); } } } }