123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using EMIS.Entities;
- using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
- using EMIS.ViewModel.StudentManage.StudentProfile;
- using EMIS.DataLogic.Repositories;
- namespace EMIS.DataLogic.UniversityManage.SpecialtyClassManage
- {
- public class ClassmajorDAL
- {
- public ClassmajorRepository ClassmajorRepository { get; set; }
- public FacultymajorRepository FacultymajorRepository { get; set; }
- public GrademajorRepository GrademajorRepository { get; set; }
- public CollegeRepository CollegeRepository { get; set; }
- public CampusRepository CampusRepository { get; set; }
- public StudentRepository StudentRepository { get; set; }
- public UserRepository UserRepository { get; set; }
- /// <summary>
- /// 查询对应的班级信息View
- /// </summary>
- /// <param name="expClassmajor"></param>
- /// <returns></returns>
- public IQueryable<ClassmajorView> GetClassmajorViewQueryable(Expression<Func<CF_Classmajor, bool>> expClassmajor)
- {
- var query = from cl in ClassmajorRepository.GetList(expClassmajor)
- join gr in GrademajorRepository.Entities
- on cl.GrademajorID equals gr.GrademajorID
- join fa in FacultymajorRepository.Entities
- on gr.FacultymajorID equals fa.FacultymajorID
- join col in CollegeRepository.Entities
- on fa.CollegeID equals col.CollegeID
- join cam in CampusRepository.Entities
- on col.CampusID equals cam.CampusID
- join c in UserRepository.Entities
- on cl.UserID equals c.UserID into gu
- from guser in gu.DefaultIfEmpty()
- join d in UserRepository.Entities
- on cl.AssistantUserID equals d.UserID into ga
- from gassis in ga.DefaultIfEmpty()
- select new ClassmajorView
- {
- ClassmajorID = cl.ClassmajorID,
- No = cl.No,
- Name = cl.Name,
- Abbreviation = cl.Abbreviation,
- EnglishName = cl.EnglishName,
- ClassNum = cl.ClassNum,
- FacultymajorID = gr.FacultymajorID,
- FacultymajorCode = fa.Code,
- FacultymajorName = fa.Name,
- GrademajorID = cl.GrademajorID,
- GrademajorCode = gr.Code,
- GrademajorName = gr.Name,
- CampusID = col.CampusID,
- CampusNo = cam.No,
- CampusName = cam.Name,
- CollegeID = fa.CollegeID,
- CollegeCode = col.No,
- CollegeName = col.Name,
- GradeID = gr.GradeID,
- SemesterID = gr.SemesterID,
- StandardID = fa.StandardID,
- EducationID = fa.EducationID,
- LearningformID = fa.LearningformID,
- LearnSystem = fa.LearnSystem,
- GraduateSchoolyearID = gr.GraduateSchoolyearID,
- GraduateValue = gr.CF_Schoolyear.Value,
- GraduateSchoolyearCode = gr.CF_Schoolyear.Code,
- UserID = cl.UserID,
- UserName = guser.Name,
- AssistantUserID = cl.AssistantUserID,
- AssistantUserName = gassis.Name,
- Fixedclassroom = cl.Fixedclassroom,
- Remark = cl.Remark,
- RecordStatus = cl.RecordStatus,
- CreateUserID = cl.CreateUserID,
- CreateTime = cl.CreateTime,
- ModifyUserID = cl.ModifyUserID,
- ModifyTime = cl.ModifyTime
- };
- return query;
- }
- /// <summary>
- /// 查询对应的班级信息View(统计对应的学生人数)
- /// </summary>
- /// <param name="expClassmajor"></param>
- /// <param name="expStudent"></param>
- /// <returns></returns>
- public IQueryable<ClassmajorView> GetClassmajorViewQueryable(Expression<Func<CF_Classmajor, bool>> expClassmajor, Expression<Func<CF_Student, bool>> expStudent)
- {
- var query = from cl in ClassmajorRepository.GetList(expClassmajor)
- join gr in GrademajorRepository.Entities
- on cl.GrademajorID equals gr.GrademajorID
- join fa in FacultymajorRepository.Entities
- on gr.FacultymajorID equals fa.FacultymajorID
- join col in CollegeRepository.Entities
- on fa.CollegeID equals col.CollegeID
- join cam in CampusRepository.Entities
- on col.CampusID equals cam.CampusID
- join sc in
- (
- from sc in StudentRepository.GetList(expStudent)
- group sc by sc.CF_Classmajor.ClassmajorID into g
- select new
- {
- ClassmajorID = g.Key,
- StudentCount = g.Count()
- })
- on cl.ClassmajorID equals sc.ClassmajorID into dsc
- from esc in dsc.DefaultIfEmpty()
- join c in UserRepository.Entities
- on cl.UserID equals c.UserID into gu
- from guser in gu.DefaultIfEmpty()
- join d in UserRepository.Entities
- on cl.AssistantUserID equals d.UserID into ga
- from gassis in ga.DefaultIfEmpty()
- select new ClassmajorView
- {
- ClassmajorID = cl.ClassmajorID,
- No = cl.No,
- Name = cl.Name,
- Abbreviation = cl.Abbreviation,
- EnglishName = cl.EnglishName,
- ClassNum = cl.ClassNum,
- FacultymajorID = gr.FacultymajorID,
- FacultymajorCode = fa.Code,
- FacultymajorName = fa.Name,
- GrademajorID = cl.GrademajorID,
- GrademajorCode = gr.Code,
- GrademajorName = gr.Name,
- CampusID = col.CampusID,
- CampusNo = cam.No,
- CampusName = cam.Name,
- CollegeID = fa.CollegeID,
- CollegeCode = col.No,
- CollegeName = col.Name,
- GradeID = gr.GradeID,
- SemesterID = gr.SemesterID,
- StandardID = fa.StandardID,
- EducationID = fa.EducationID,
- LearningformID = fa.LearningformID,
- LearnSystem = fa.LearnSystem,
- GraduateSchoolyearID = gr.GraduateSchoolyearID,
- GraduateValue = gr.CF_Schoolyear.Value,
- GraduateSchoolyearCode = gr.CF_Schoolyear.Code,
- UserID = cl.UserID,
- UserName = guser.Name,
- AssistantUserID = cl.AssistantUserID,
- AssistantUserName = gassis.Name,
- Fixedclassroom = cl.Fixedclassroom,
- StudentCount = esc.StudentCount == null ? 0 : esc.StudentCount,
- Remark = cl.Remark,
- RecordStatus = cl.RecordStatus,
- CreateUserID = cl.CreateUserID,
- CreateTime = cl.CreateTime,
- ModifyUserID = cl.ModifyUserID,
- ModifyTime = cl.ModifyTime
- };
- return query;
- }
- /// <summary>
- /// 查询班级信息对应的学生信息BaseStudentView
- /// </summary>
- /// <param name="expClassmajor"></param>
- /// <param name="expStudent"></param>
- /// <returns></returns>
- public IQueryable<StudentBaseView> GetStudentBaseViewQueryable(Expression<Func<CF_Classmajor, bool>> expClassmajor, Expression<Func<CF_Student, bool>> expStudent)
- {
- var query = from cl in ClassmajorRepository.GetList(expClassmajor)
- join stu in StudentRepository.GetList(expStudent)
- on cl.ClassmajorID equals stu.ClassmajorID
- join gr in GrademajorRepository.Entities
- on cl.GrademajorID equals gr.GrademajorID
- join fa in FacultymajorRepository.Entities
- on gr.FacultymajorID equals fa.FacultymajorID
- join us in UserRepository.Entities
- on stu.UserID equals us.UserID
- select new StudentBaseView
- {
- UserID = stu.UserID,
- LoginID = us.LoginID,
- UserName = us.Name,
- SexID = stu.SexID,
- IDNumber = stu.IDNumber,
- StudentStatus = stu.StudentStatus,
- InSchoolStatusID = stu.InSchoolStatusID,
- ClassmajorID = stu.ClassmajorID,
- ClassmajorNo = cl.No,
- ClassmajorName = cl.Name,
- ClassNum = cl.ClassNum == null ? 1 : cl.ClassNum,
- GradeID = gr.GradeID,
- SemesterID = gr.SemesterID,
- GrademajorID = cl.GrademajorID,
- GrademajorCode = gr.Code,
- GrademajorName = gr.Name,
- FacultymajorID = gr.FacultymajorID,
- FacultymajorCode = fa.Code,
- FacultymajorName = fa.Name
- };
- return query;
- }
- }
- }
|