How can we turn off lazy loading?(Entity framework interview questions with answers)
In case you are not aware of "lazy loading" , please first read this entity framework interview question "What is lazy loading in entity framework ?"
Below is a great ADO.NET Entity framework interview question video created by www.questpond.com which shows how to do CRUD using Entity framework.
The opposite of lazy loading eager loading. In eager loading we load the objects beforehand. So the first thing is we need to disable lazy loading by setting "LazyLoadingEnabled" to false.
So now we have to explicitly tell EF what objects we want to load by using the "include" function. Below is a simple sample code where we tell EF to load customer as well as address objects by using the "include" function.
So now the customer object and the related address objects will be loaded in one query rather than multiple queries.
Thanks questpond.com to provide this ADO.NET Entity framework interview question.