Upload
pallavi-patil
View
216
Download
0
Embed Size (px)
DESCRIPTION
Entity Framework N+1 Query
Citation preview
using (var context = new SchoolEntities()){ foreach (var department in context.Departments) { foreach (var course in department.Courses) { Console.WriteLine("{0}: {1}", department.Name, course.Title); } }}
============================================
using (var context = new SchoolEntities()){ foreach (var department in context.Departments.Include("Courses")) { foreach (var course in department.Courses) { Console.WriteLine("{0}: {1}", department.Name, course.Title); } }}