using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Repositories; using EMIS.ViewModel.SupervisionManage; using System.Linq.Expressions; using EMIS.Entities; namespace EMIS.DataLogic.SupervisionManage { public class SupEvaluationDAL { public LessonRecordRepository LessonRecordRepository { get; set; } public ProjectRecordRepository ProjectRecordRepository { get; set; } public SchoolyearRepository SchoolyearRepository { get; set; } public SupervisionCollegeRepository SupervisionCollegeRepository { get; set; } public UserRepository UserRepository { get; set; } public CoursematerialRepository CoursematerialRepository { get; set; } public CoursesTimeRepository CoursesTimeRepository { get; set; } public StaffRepository StaffRepository { get; set; } public IQueryable GetSupEvaluationViewQueryable(Expression> exp, Expression> ProjectRecordExp,Expression> supervisorExp) { var query = ( from record in LessonRecordRepository.GetList(exp) from schoolyear in SchoolyearRepository.Entities.Where(x => x.SchoolyearID == record.SchoolyearID) from college in SupervisionCollegeRepository.Entities.Where(x => x.SupervisionCollegeID == record.SupervisionCollegeID) from user in UserRepository.Entities.Where(x => x.UserID == record.UserID) from course in CoursematerialRepository.Entities.Where(x => x.CoursematerialID == record.CoursematerialID) from time in CoursesTimeRepository.Entities.Where(x => x.CoursesTimeID == record.CoursesTimeID) from creator in UserRepository.Entities.Where(x => x.UserID == record.CreateUserID) from staff in StaffRepository.Entities.Where(x => x.UserID == user.UserID).DefaultIfEmpty().Where(supervisorExp) select new SupEvaluationView { LessonRecordID=record.LessonRecordID, ProjectRecordID=null, SchoolYearID = record.SchoolyearID, SchoolyearCode = schoolyear.Code, LessonDate = record.LessonDate, Location = record.Location, SupervisionCollegeID = record.SupervisionCollegeID, SupervisionCollegeName = college.Name, UserID = record.UserID, UserName = user.Name, SupervisionTypeID=null, CoursematerialID = record.CoursematerialID, CourseName = course.CourseName, Weekday = record.Weekday, CoursesTimeID = record.CoursesTimeID, StartTimes = time.StartTimes, EndTimes = time.EndTimes, TotalScore = record.TotalScore, Content = record.Content, Advise = record.Record, CreateUserID = record.CreateUserID, CreateUserName = creator.Name }).Union( from precord in ProjectRecordRepository.GetList(ProjectRecordExp) from pschoolyear in SchoolyearRepository.Entities.Where(x => x.SchoolyearID == precord.SchoolyearID) from pcollege in SupervisionCollegeRepository.Entities.Where(x => x.SupervisionCollegeID == precord.SupervisionCollegeID) from puser in UserRepository.Entities.Where(x => x.UserID == precord.UserID) from pcourse in CoursematerialRepository.Entities.Where(x => x.CoursematerialID == precord.CoursematerialID) from ptime in CoursesTimeRepository.Entities.Where(x => x.CoursesTimeID == precord.CoursesTimeID) from pcreator in UserRepository.Entities.Where(x => x.UserID == precord.CreateUserID) from staff in StaffRepository.Entities.Where(x => x.UserID == puser.UserID).DefaultIfEmpty().Where(supervisorExp) select new SupEvaluationView { LessonRecordID = null, ProjectRecordID = precord.ProjectRecordID, SchoolYearID = precord.SchoolyearID, SchoolyearCode = pschoolyear.Code, LessonDate = precord.ProjectDate, Location = precord.Location, SupervisionCollegeID = precord.SupervisionCollegeID, SupervisionCollegeName = pcollege.Name, UserID = precord.UserID, UserName = puser.Name, SupervisionTypeID=precord.SupervisionTypeID, CoursematerialID = precord.CoursematerialID, CourseName = pcourse.CourseName, Weekday = precord.Weekday, CoursesTimeID = precord.CoursesTimeID, StartTimes = ptime.StartTimes, EndTimes = ptime.EndTimes, TotalScore = precord.TotalScore, Content = precord.Content, Advise = precord.Advise, CreateUserID = precord.CreateUserID, CreateUserName = pcreator.Name }); return query; } } }