Reference()和Collection() 方法
IList<Student> studList = context.Students.ToList<Student>();
Student std = studList.Where(s => s.StudentID == 1).FirstOrDefault<Student>();
//Loads Standard for particular Student only (seperate SQL query)
context.Entry(std).Reference(s => s.Standard).Load();
//Loads Courses for particular Student only (seperate SQL query)
context.Entry(std).Collection(s => s.Courses).Load();
时间: 2024-11-09 06:19:29