Archives for the 'LINQ' Category

LINQ to Entities: Deferred Execution and Lazy Loading

How do deferred execution and lazy loading work in LINQ to Entities (Entity Framework)? Let’s find out!
First, some sample data. We don’t want to make it too simple, so let’s have three entities:

Employee, who belongs to a Department
Department, which is under a Functional Group
Functional Group

The data:
Functional Groups

Id
Description

1
Functional Group 01

2
Functional Group 02

Departments

Id
Description
FunctionalGroupId

1
Department 01
1

2
Department 02
2

3
Department 03
2

Employees

Id
First Name
Last […]

9 November 2010 | LINQ, Entity Framework, .NET, C# | 4 Comments