コード例 #1
0
        public void EagerLoadTeacherPupils()
        {
            SchoolContext ctx = new SchoolContext();

            List<Teacher> teachers = ctx.Teachers.Include("Pupils").ToList();

            Assert.IsTrue(teachers.Count == 1);
        }
コード例 #2
0
        public void EagerLoadPupilsTeacher()
        {
            SchoolContext ctx = new SchoolContext();

            Pupil pupil = ctx.Pupils.Include("Teacher").Single(x => x.FirstName == "Sam");

            Assert.IsTrue(pupil.Teacher.LastName == "Lanes");
        }