Showing posts with label Eager Loading. Show all posts
Showing posts with label Eager Loading. Show all posts

30 April 2024

Eager Loading, Lazy Loading

Eager Loading, Lazy Loading

Eager Loading helps you to load all your needed entities at once; i.e., all your child entities will be loaded at single database call. This can be achieved, using the Include method, which returs the related entities as a part of the query and a large amount of data is loaded at once.

User usr = dbContext.Users.Include(=> a.UserDetails).FirstOrDefault(=> a.UserId == userId);

Lazy Loading
It is the default behavior of an Entity Framework, where a child entity is loaded only when it is accessed for the first time. It simply delays the loading of the related data, until you ask for it.

User usr = dbContext.Users.FirstOrDefault(=> a.UserId == userId);

Implementing OAuth validation in a Web API

 I mplementing OAuth validation in a Web API Implementing OAuth validation in a Web API using C# typically involves several key steps to sec...