//得到选择课程的学生表,是当前学年学期的选课的学生,往年的要专门查询查Selecion表 public IList<Student> GetSelectCourseStudent(int courseId) { ICourseDao courseDao = new CourseDao(sessionFactory); Course selectedCourse = courseDao.Get(courseId); string studyYear = selectedCourse.courseStudyYear; string term = selectedCourse.courseTerm; ISelectionDao selectionDao = new SelectionDao(sessionFactory); //Selection表,是否为空?否则就是NullException IList<Selection> selectionList=selectionDao.GetSelectionByCourse(courseId,studyYear,term); //IList<Student> studentList=null; //(还未分配空间,一定要分配了空间给一个对象才可以用其实例方法) IList<Student> studentList =new List<Student>(); IStudentDao studentDao = new StudentDao(sessionFactory); for (int i = 0; i < selectionList.Count; i++) { studentList.Add(studentDao.Get(selectionList[i].ID.selectionStudentID)); } return studentList; }
public Student GetStuentByID(string userId) { int studentId = Int32.Parse(userId); IStudentDao studentDao = new StudentDao(sessionFactory); return studentDao.Get(studentId); }