I am selecting an Anonymous Object in Entity Framework. I am including Sub-Properties into the Anonymous Object.
This is very similar to the question here. The difference is, I am including multiple (two) levels deep.
For example:
context.Items.Include(x => x.ChildItems.Select(y => y.House)).ToList();
// ^^^^^^^^^^^^^^^^^^^^^
With the basic selection above, ChildItems and their associated House are all populated. But if I try to select an anonymous object like below, the ChildItems exist, but their House item is null.
context.Items.Include(x => x.ChildItems.Select(y => y.House))
.Select(x => new
{
x.ItemID,
x.OtherInfo,
x.ChildItems,
}).ToList();