I am trying to delete a list of items from a database with entity framework, however I can't get the sub lists not to load,
essentially I have a list for which each item of that list contains a 2 list, I want to not load the sub lists but just the list it self.
How do I only load the list and not its sub lists?
It's possible that the sub lists are being LazyLoaded when they are evaluated. You can turn Lazy Loading off with
DbContext.Configuration.LazyLoadingEnabled = false;
More details here . I typically turn LazyLoading off in the constructor of my context and eager load anything I need with include statements. Lazy Loading can also cause performance issues. If you loop through a lazy loading collection you'll end up with one database hit per item in the collection.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.