ExamSettingDAL.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMISOnline.Entities;
  6. using EMISOnline.DataLogic.Repositories;
  7. using System.Linq.Expressions;
  8. namespace EMISOnline.DataLogic.ExamSetting
  9. {
  10. public class ExamSettingDAL
  11. {
  12. public onlinetestRepository OnlinetestRepository { get; set; }
  13. public paperRepository PaperRepository { get; set; }
  14. public StudentRepository StudentRepository { get; set; }
  15. public ExamResultRepository ExamResultRepository { get; set; }
  16. public ExamineeAnswerRepository ExamineeAnswerRepository { get; set; }
  17. public IQueryable<test_onlinetest> GetOnlinetestList(Expression<Func<test_onlinetest, bool>> testExpression)
  18. {
  19. var query = from c in OnlinetestRepository.Entities.Where(testExpression)
  20. select c;
  21. return query.AsQueryable();
  22. }
  23. public IQueryable<test_onlinetest> GetStudentOnlinetestList(Expression<Func<test_onlinetest, bool>> testExpression,string UserID)
  24. {
  25. var query = from c in OnlinetestRepository.Entities.Where(testExpression)
  26. //join r in ExamResultRepository.Entities on c.onlinetest_id equals r.onlinetest_id
  27. //where r.user_id == UserID
  28. select c;
  29. return query.AsQueryable();
  30. }
  31. public IQueryable<test_paper> GetPaperList(Expression<Func<test_paper, bool>> testExpression)
  32. {
  33. var query = from paper in PaperRepository.Entities.Where(testExpression)
  34. where paper.test_paper_parent_id == 0 || paper.test_paper_parent_id == null
  35. select paper;
  36. return query.AsQueryable();
  37. }
  38. public IQueryable<CF_Student> GetExamUsers(decimal testid)
  39. {
  40. var query = from student in StudentRepository.Entities
  41. select student;
  42. return query.Take(10);
  43. }
  44. public ExamResult GetExam(string userid, decimal test_id)
  45. {
  46. //var query = from test in ExamResultRepository.Entities
  47. // where test.onlinetest_id == test_id
  48. // where test.user_id == userid
  49. // select test;
  50. var query = ExamResultRepository.UnitOfWork.Set<ExamResult>().Include("test_onlinetest").Where(q=>q.onlinetest_id==test_id&&q.user_id==userid);
  51. return query.SingleOrDefault();
  52. }
  53. }
  54. }