Monday, September 1, 2014

Eager Loading with DBContext

Eager loading is the process, where a query for one type of entity also loads related entities as part of the query. Eager loading is achieved by use of the 'Include' method.




Below code snippet shows eager loading where Standard entity will also be loaded with Student entity using Include method.


Lazy Loading with DBContext

Lazy loading means delaying the loading of related data until you specifically request it. For example, in below code snippet, we first load all the students from the database then it will load address of particular student when we access StudentAddress entity.




To learn more about MVC please go to the following link.

MVC Articles

Enjoy coding and reading.


Post a Comment