I have got entity:
Entry
{
public virtual ICollection<Content> Contents { get; set; }
}
I need to get the Entry that contains filtered Contents.
var entryWithFilteredContents = dbContext.Entry.Single(). ???
/*Load(entry=>entry.Contents) Where(content=> content.Value > 10)*/
Now when I write entryWithFilteredContents.Contents I expect to receive only contents that have Value greater then 10. I know i can get an var entry = db.Context.Entry.Single() and then var contents = entry.Contents.Where(content=> content.Value > 10) but that don’t satisfy my needs.
This is not something EF currently supports out of the box.
The usual workaround is to first select a projection, like this:
You can of course also return any projection directly (and potentially save some database round-trips), but will need a non-anonymous type in order to have the result escape the current method.