using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Repositories; using EMIS.ViewModel.DQPSystem; using System.Linq.Expressions; using EMIS.Entities; using EMIS.ViewModel; namespace EMIS.DataLogic.DQPSystem { public class CommunicateDAL { public SOCRepository SOCRepository { get; set; } public StaffRepository StaffRepository { get; set; } public StaffProfileRepository StaffProfileRepository { get; set; } public ClassmajorRepository ClassmajorRepository { get; set; } public UserRepository UserRepository { get; set; } public SOCStaffRepository SOCStaffRepository { get; set; } public StudentContactRepository StudentContactRepository { get; set; } public IQueryable GetTeacherCommunicateViewQueryable(Expression> staffExp, Expression> socExp) { var sql = (from soc in SOCRepository.GetList(socExp) from teacher in SOCStaffRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.SOCID == soc.SOCID) from staff in StaffRepository.Entities.Where(staffExp).Where(x => x.UserID == teacher.UserID) from student in soc.CF_Student from user in UserRepository.Entities.Where(x => x.UserID == student.UserID) from contact in StudentContactRepository.Entities.Where(x => x.UserID == student.UserID) from classmajor in ClassmajorRepository.Entities.Where(x => x.ClassmajorID == student.ClassmajorID) group student by new TeacherCommunicateView { UserID = student.UserID, ClassmajorID = classmajor.ClassmajorID, ClassmajorNo = classmajor.No, ClassmajorName = classmajor.Name, LoginID = user.LoginID, Name = user.Name, QQ = contact.QQ } into g select g.Key); return sql; } public IQueryable GetStudentCommunicateViewQueryable(Expression> studentExp, Expression> socExp) { var sql = (from soc in SOCRepository.GetList(socExp) from me in soc.CF_Student.AsQueryable().Where(studentExp) from teacher in SOCStaffRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.SOCID == soc.SOCID) from user in UserRepository.Entities.Where(x => x.UserID == teacher.UserID) from staff in StaffRepository.Entities.Where(x => x.UserID == teacher.UserID) from profile in StaffProfileRepository.Entities.Where(x => x.UserID == staff.UserID) group staff by new StudentCommunicateView { UserID = staff.UserID, RoleOrder = 0, Role = "老师", ClassmajorID = null, ClassmajorNo = null, ClassmajorName = null, LoginID = user.LoginID, Name = user.Name, QQ = profile.QQ } into g select g.Key) .Concat( from soc in SOCRepository.GetList(socExp) from me in soc.CF_Student.AsQueryable().Where(studentExp) from student in soc.CF_Student from user in UserRepository.Entities.Where(x => x.UserID == student.UserID) from contact in StudentContactRepository.Entities.Where(x => x.UserID == student.UserID) from classmajor in ClassmajorRepository.Entities.Where(x => x.ClassmajorID == student.ClassmajorID) group student by new StudentCommunicateView { UserID = student.UserID, RoleOrder = 1, Role = "学生", ClassmajorID = classmajor.ClassmajorID, ClassmajorNo = classmajor.No, ClassmajorName = classmajor.Name, LoginID = user.LoginID, Name = user.Name, QQ = contact.QQ } into g select g.Key); return sql; } } }