Feature: Reposiories Get*WithInclude() where related enitities are eagerly loaded
See original GitHub issueIn relation to #157 I nice feature would be to have built in support for *eager loading of child entities. While it is understood that the current limitation is that this is not supported by NHibernate implementing this would be a nice addition. eg:
/// <summary>
/// Same behaviour as Get() but also eagerly loads any included entities
/// </summary>
/// <param name="aKey">Primary key</param>
/// <returns>Record if found, NullException otherwise</returns>
public StructureDivisionEntity GetWithInclude(long aKey)
{
return GetAllWithInclude()
.Include(e => e.Structure)
.Include(e => e.ParentStructureDivision.Structure)
.First(r => r.Id == aKey);
}
/// <summary>
/// Same behaviour as GetAll() but also eagerly loads any included entities
/// </summary>
/// <returns>Records if found, empty list otherwise</returns>
public IQueryable<StructureDivisionEntity> GetAllWithInclude()
{
return GetAllWithInclude()
.Include(e => e.Structure)
.Include(e => e.ParentStructureDivision.Structure);
}
The implementation above could be improved by doing a dynamic scan of referenced entities and providing the depth of recursion for referenced entities
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Eager Loading of Related Data - EF Core
Entity Framework Core will automatically fix-up navigation properties to any other entities that were previously loaded into the context ...
Read more >Entity Framework Core Repository Pattern Eager Load
In my repository, I have an interface similar to this. Using DBSet, I am able to use the Find method to generically find...
Read more >Eager Loading In Repository Pattern Entity Framework Core
The method EntityWithEagerLoad() takes 2 arguments, one is filter criteria and another is an array of entities which we want to eager load....
Read more >Eager Loading in Entity Framework
Eager loading is the process whereby a query for one type of entity also loads related entities as part of the query, so...
Read more >Generic Entity Framework Repository with Eager Loading
In this post am going to explain how we can write Generic repository for Entity framework. The implementation is based on the Repository...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
You can add reference of EF to your application layer. Then call _repository.GetAll().Include(…)
You can say that: “Depending EF is not right on app layer” but when we add Include to repository, you will be depend on EF either. So, I think no problem to add it unless you don’t change EF in the future. In this way, you can also use Async LinQ entensions.
thanks,i used this property in my project today