Entity Framework Lazy Download in .NET 3.5

Due to server limitations, I am limited to .Net 3.5, I used lazy booting with Linq to SQL, but have since switched to Entity Framework. L2E does not have lazy loading in 3.5, while L2S. Is there a way to restore the templates somehow to achieve this?

+4
source share
1 answer

You must explicitly call the boot method in EF 1 / .NET 3.5.

So, before you access a related collection or entity that is not loaded, you should call something like:

Examples:

if (!person.Pets.IsLoaded) person.Pets.Load(); if (!person.Address.IsLoaded) person.Address.Load(); 

Of course, this is so ugly, but the way it worked in this version.

Learn more from Microsoft Blogs here:

http://blogs.microsoft.co.il/blogs/idof/archive/2008/08/20/entity-framework-and-lazy-loading.aspx

+4
source

Source: https://habr.com/ru/post/1342581/


All Articles