In basic I'm looking for the simplest way to get an associated collection of an entity in one request.
using (var context = new DbContext())
{
context.Users.Attach(user);
context.Entry(user)
.Collection(f => f.Followers)
.Query()
.Where(x => x.Whatever)
//.Collection(r => r.Requests) doesn't work
//.Collection(b => b.Blocks) doesn't work
.Load();
}
I'm aware that I could split these up into 3 different requests, but I'm wanting only one trip to the db.
Alternatively I was able to pull this off:
var user = context.Users
.Include(f => f.Followers)
.Include(r => r.Requests)
The problem with the approach above is I'm unable to filter the collections in the include with a .Where clause.
This question is very much: EF 6 filtering child collections
As well as: Entity Framework Query multiple collections
Neither of which were able to be pulled off with one request, so I'm guessing its not possible?