Showing posts with label eager loading. Show all posts
Showing posts with label eager loading. Show all posts

Monday, March 30, 2020

Entity Framework Core Eager, Explicity and Lazy Loading

Eager Loading in Entity Framework Core

Eager loading loads the data from the main table and the related / dependent tables together during the initial load. To perform eager loading we use the Include() method. Let us consider our sample tables Employee and Department to implement Eager loading.

The Employee table which has a Foreign Key DepartmentId referencing to the Department table. We will load the data from the Employee table and also load the corresponding data from the Department table using Eager Loading.

EFCore - Loading Dependent table data

When we Generate the Model classes using Entity Framework Core it creates Navigational properties for the Model classes which have a Foreign Key relation. Using these Navigational properties we can load dependent data in different ways.

In our previous examples we have seen the Employee table has Foreign Key relation with the Department table and the Country table, when we generate the Model classes using Entity Framework Core the Employee class will have reference to the related classes, the Employee model class will be as follows.

Thursday, November 1, 2018

Eager loading Module example in Angular 6

Eager loading is the default type of module loading in Angular, this approach is suitable for smaller applications where all the dependent modules are loaded initially when the application is loaded in the browser.

In eager loading we import all the dependent components into the main module and map the components to different routes in the module routing. When a specific route is invoked the corresponding component is loaded in the root component.

This example is similar to the one which we saw in the Routing example. We import 2 components About & Contact in the application module and map them in the modules routing configuration.

Tuesday, October 30, 2018

Eager, Lazy and Preloading modules in Angular

In the previous posts we have seen about Feature modules which are added to the root module for better modularity and maintainability of the Angular applications. Depending on the need there are 3 different ways in which modules can be loaded in an Angular application.

Eager loading
Laze loading &
Preloading