问题
I actually had a previous post regarding the topic that I first thought was an EF issue. I then realized that EF has a lazy loading configuration built in and it appears that the Generic Unit of Work and Repository Pattern framework is not loading related entities automatically.
When I use the .Include() extension in the DBSet<> property, the relationships begin populating without issue.
This works:
var list = (new DBContext()).Teams.Include(a => a.Creator).AsQueryable().ToList();
Using the repository does not work:
var list = _repo.Queryable().ToListAsync();
Any help, please?
UPDATE FIX:
Thanks to DLeh for the idea! Here's my fix:
var list = _repo.Queryable().Include(a => a.Creator).ToListAsync();
回答1:
It's solved. Thanks to DLeh for the idea.
var list = _repo.Queryable().Include(a => a.Creator).ToListAsync();
来源:https://stackoverflow.com/questions/29542993/generic-unit-of-work-and-repository-pattern-does-not-load-related-entities