Text version of the video
[ Ссылка ]
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
[ Ссылка ]
Slides
[ Ссылка ]
LINQ to SQL Tutorial - All Text Articles & Slides
[ Ссылка ]
LINQ to SQL Tutorial Playlist
[ Ссылка ]
Dot Net, SQL, Angular, JavaScript, jQuery and Bootstrap complete courses
[ Ссылка ]
In this video we will discuss the concept of Lazy loading in LINQ to SQL with an example.
In this example there is a One-to-Many relationship between Department and Employee entities. A Department can have 1 or more employees. When Departments are loaded the related entities (Employee entities) are not loaded. Employee entities are only loaded when we iterate thru the employee objects belonging to a given department.
To prove this, uncomment the following line and run the console application again. Notice that there is one query to retrieve all the departments and 3 queries to retrieve the employees belonging to each department.
//dbContext.Log = Console.Out;
So, what is Lazy Loading
Lazy Loading means the related entities are not loaded until we iterate thru them or data bind them. By default, LINQ to SQL loads related entities by using Lazy Loading.
In our next video, we will discuss how to change this behavior and eager load the related entities.
![](https://s2.save4k.ru/pic/rTxZT-u7K_o/mqdefault.jpg)