-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is virtual for lazy loading still needed? #3318
Comments
That's what I thought. If virtual is still needed then the sample code is misleading and or wrong or just superfluous as it calls .Include when a non virtual property will already be fully loaded Sent from my Samsung Galaxy smartphone. -------- Original message -------- This is an unofficial answer in the form of a question, but how would lazy loading be implemented without an overridden property? Reply to this email directly or view it on GitHubhttps://github.com//issues/3318#issuecomment-145380507. |
@angelsix EF7 does not lazy-load automatically through navigation properties so that does not play as a reason to make the properties virtual. |
Ah ok. My understanding was if a single item isn't marked as virtual, it will fully load when you load the parent item. Only collections/lists didn't load automatically. So a Product would fully load, but an ICollection would not of. Is my understanding wrong? I am sure in EF6 I had to mark single navigation properties on a class as virtual otherwise they got eager loaded when the parent object was loaded. |
What you are describing sounds a bit like how things work in NHibernate: If you specify 'lazy = false' on a property, it will get eager loaded; collections default to 'lazy = true' and references default to 'lazy = false'. In EF6 you make navigation properties virtual to enable the creation of proxy types in which we can embed the ability to lazy load. EF6 will never eager load anything automatically (you have to ask for it in the query), and if lazy loading is enabled it will work the same for collection and reference properties. |
@rowanmiller do you know if we have anything in the documentation, feature list, roadmap or blog posts that mentions the status of lazy loading in EF7? |
It's listed on our roadmap as a high priority feature but something we'll implement based on feedback https://github.com/aspnet/EntityFramework/wiki/Roadmap#high-priority-features |
+1 for Lazy load |
In the past. I have used the dynamic linq (https://github.com/mrKrizz/dynamic-linq) with lazy load. but in the ef7, without the lazy load, I cannot use the dynamic linq anymore. sad. |
I ask because the UnicornStore demo doesnt set for example Product as virtual in CarlItem and OrderLine, yet it does .Include(i => i.Product) which wouldnt be needed if it wasn't virtual lazy loaded in the first place.
The text was updated successfully, but these errors were encountered: