/// <summary> /// 获取学籍信息 /// </summary> /// <param name="value"></param> /// <returns></returns> public Schoolroll GetRoll(string value) { var schoolroll = new Schoolroll(); using (var dbcontext = new srContext()) { schoolroll = dbcontext.Schoolroll.FirstOrDefault(u => u.Sno == value); } return(schoolroll); }
/// <summary> /// 获取一个学生信息 /// </summary> /// <param name="no"></param> /// <returns></returns> public Student FindStudent(string no) { var student = new Student(); using (var dbcontext = new srContext()) { student = dbcontext.Student.FirstOrDefault(u => u.Sno == no); } var schoolroll = new Schoolroll(); var function = new SchoolrollMethod(); schoolroll = function.GetRoll(no); student.Schoolroll = schoolroll; return(student); }
/// <summary> /// 获取所有学生信息 /// </summary> /// <returns></returns> public List <Student> ReadDB() { List <Student> students = new List <Student>(); var schoolroll = new Schoolroll(); var function = new SchoolrollMethod(); using (var dbcontext = new srContext()) { foreach (var value in dbcontext.Student) { schoolroll = function.GetRoll(value.Sno); value.Schoolroll = schoolroll; students.Add(value); } } return(students); }