I have two objects that have many, many relationships with each other.
I use the Entity Framework in the first approach to the database.
My Database Profiler shows that every time I select one set of objects A, it loads a different set of objects B for each element in A. I assumed that this will not happen with lazy loading or that B will be selected when accessed through the navigation property.
The code for accessing objects uses a general approach where objects are my DbContext
public virtual IQueryable<T> GetAll()
{
IQueryable<T> query = entities.Set<T>();
return query;
}
Both navigation properties are implemented as virtual ICollection<T>, and I am Configuration.LazyLoadingEnabled = trueexplicitly set in my constructor DbContext.
Am I missing something, or am I approaching it wrong? Should I just remove the navigation properties and explicitly load what I need with other requests?
source
share