using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMISOnline.Entities; using EMISOnline.DataLogic.Repositories; using System.Linq.Expressions; namespace EMISOnline.DataLogic.ExamSetting { public class ExamSettingDAL { public onlinetestRepository OnlinetestRepository { get; set; } public paperRepository PaperRepository { get; set; } public StudentRepository StudentRepository { get; set; } public ExamResultRepository ExamResultRepository { get; set; } public ExamineeAnswerRepository ExamineeAnswerRepository { get; set; } public IQueryable GetOnlinetestList(Expression> testExpression) { var query = from c in OnlinetestRepository.Entities.Where(testExpression) select c; return query.AsQueryable(); } public IQueryable GetStudentOnlinetestList(Expression> testExpression,string UserID) { var query = from c in OnlinetestRepository.Entities.Where(testExpression) //join r in ExamResultRepository.Entities on c.onlinetest_id equals r.onlinetest_id //where r.user_id == UserID select c; return query.AsQueryable(); } public IQueryable GetPaperList(Expression> testExpression) { var query = from paper in PaperRepository.Entities.Where(testExpression) where paper.test_paper_parent_id == 0 || paper.test_paper_parent_id == null select paper; return query.AsQueryable(); } public IQueryable GetExamUsers(decimal testid) { var query = from student in StudentRepository.Entities select student; return query.Take(10); } public ExamResult GetExam(string userid, decimal test_id) { //var query = from test in ExamResultRepository.Entities // where test.onlinetest_id == test_id // where test.user_id == userid // select test; var query = ExamResultRepository.UnitOfWork.Set().Include("test_onlinetest").Where(q=>q.onlinetest_id==test_id&&q.user_id==userid); return query.SingleOrDefault(); } } }