/// <summary> /// 根据编写返回班级 /// </summary> /// <param name="gradeid"></param> /// <returns></returns> public string GetClassName(int gradeid) { List <Student> ulist = new List <Student>(); string className = ""; try { using (var content = new AptechSchoolEntities()) { var query = from s in content.SchoolClasses where s.GradeId == gradeid select s; foreach (var s in query) { className = s.ClassName; } } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(className); }
public List <Student> GetALLUsers() { List <Student> ulist = new List <Student>(); try { using (AptechSchoolEntities context = new AptechSchoolEntities()) { var query = from e in context.Students select e; foreach (var item in query) { Student stu = new Student(); stu.SAddress = item.SAddress; stu.SAge = item.SAge; stu.SClass = item.SClass; stu.SGrade = item.SGrade; stu.SId = item.SId; stu.SName = item.SName; stu.SPicture = item.SPicture; ulist.Add(stu); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(ulist); }
public List <Educational> GetALLEducational() { List <Educational> edulist = new List <Educational>(); using (AptechSchoolEntities context = new AptechSchoolEntities()) { //1.using LINQ to Entities query var query = from e in context.Educationals select e; foreach (var item in query) { Educational edu = new Educational(); edu.EId = item.EId; edu.EducationalName = item.EducationalName; edulist.Add(edu); } } return(edulist); }