Let's say I have 2 entities (1-to-many) relation: Component
and Part
like so:
public Component
{
string CompName { get; set; }
byte[] CompBlob { get; set; }
ICollection<Part> Parts { get; set; }
}
public Part
{
string PartName { get; set; }
byte[] PartBlob { get; set; }
}
When I load a Component
, I want to always load its Parts
for this particular entity.
I want to know how to select / project a list of components so that EF will not load additional inner properties (eg: only CompName
and PartName
to be loaded but not CompBlob
and inner PartBlob
).
Maybe something like below, but how to apply a selector for Parts
?
//
dbContext.Components.Include(c => c.Parts).Where(filterComponents).Select(.?.)
//
If needed, I have LazyLoadingEnabled
set to false