using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Repositories; using EMIS.ViewModel.SystemView; using System.Linq.Expressions; using EMIS.Entities; using EMIS.ViewModel.Students; namespace EMIS.DataLogic.StudentSystem.StudentMaterial { public class StudentRecordDAL { public StudentRepository StudentRepository { get; set; } public StudentProfileRepository ProfileRepository { get; set; } public StudentContactRepository ContactRepository { get; set; } public RecruitstudentsRepository RecruitsRepository { get; set; } public ClassmajorRepository ClassRepository { get; set; } public GrademajorRepository GradeRepository { get; set; } public FacultymajorRepository FacultyRepository { get; set; } public StudentEditControlRepository ControlRepository { get; set; } public StudentEditObjectsRepository StudentEditObjectsRepository { get; set; } public StudentContrastRepository StudentContrastRepository { get; set; } public CollegeRepository CollegeRepository { get; set; } public SchoolyearRepository SchoolyearRepository { get; set; } public StudentRecordView GetStudentByStudentNo(Guid StudentID) { var query = from student in StudentRepository.Entities join profile in ProfileRepository.Entities on student.UserID equals profile.UserID join contact in ContactRepository.Entities on profile.UserID equals contact.UserID join recruits in RecruitsRepository.Entities on contact.UserID equals recruits.UserID join cla in ClassRepository.Entities on student.ClassmajorID equals cla.ClassmajorID join grade in GradeRepository.Entities on cla.GrademajorID equals grade.GrademajorID join faculty in FacultyRepository.Entities on grade.FacultymajorID equals faculty.FacultymajorID join college in CollegeRepository.Entities on faculty.CollegeID equals college.CollegeID join schoolyear in SchoolyearRepository.Entities on new { Years = grade.GradeID, SchoolcodeID = grade.SemesterID } equals new { Years = (int?)schoolyear.Years, SchoolcodeID = (int?)schoolyear.SchoolcodeID } where student.UserID == StudentID select new StudentRecordView() { IsDreamProject = profile.IsDreamProject == true, Career=student.Career, CardNo=student.CF_StudentAccount.CardNo, BankName=student.CF_StudentAccount.BankName, UserID = student.UserID, LoginID = student.Sys_User.LoginID, UserName = student.Sys_User.Name, PhotoUrl = student.PhotoUrl, UsedName = profile.UsedName, SexID = student.SexID.Value, BirthDate = student.BirthDate, Nation = student.NationID, Politics = student.PoliticsID, CertificatesType = student.CertificatesType, IDNumber = student.IDNumber, CultureModel = profile.CultureModelID, StudentType = student.StudentType, InSchoolStatusID=student.InSchoolStatusID, StudentStatus = student.StudentStatus, EntranceDate = recruits.EntranceDate, EntranceWay = recruits.EntranceWayID, ExamineeNum = recruits.ExamineeNum, ExamineeType = recruits.ExamineeType, Features = recruits.FeaturesID, CollegeName = college.Name, Score = recruits.Score, Territorial = recruits.TerritorialID, Area = student.CF_Recruitstudents.Area, Place = profile.Place, BornPlace = profile.BornPlace, Healthy = profile.HealthStateID, Specialty = profile.Specialty, Height = profile.Height, Weight = profile.Weight, Email = contact.Email, QQ = contact.QQ, Dormitory = contact.Dormitory, Telephone = contact.Telephone, Mobile = contact.Mobile, HomeAddress = contact.HomeAddress, WorkUnit = contact.WorkUnit, Zipcode = contact.ZIPCode, Recipient = contact.Recipient, PlanningGraduateDate = student.PlanningGraduateDate, GradeName = grade.Name, GradeCode = grade.Code, StandardID = grade.CF_Facultymajor.StandardID, ClassID=cla.ClassmajorID, ClassName = cla.Name, LearnSystem = faculty.LearnSystem, No = cla.No, EducationID = faculty.EducationID, LearningformID = faculty.LearningformID, LearningstyleID = faculty.LearningstyleID, Remarks = student.Remark, FacultymajorID = grade.FacultymajorID, StartSchoolcodeID = grade.SemesterID, StartSchoolyearValue = schoolyear.Value }; return query.SingleOrDefault(); } } }