I can reproduce it, but in my opinion, this is expected. Why add the the root prefetchpath entity as a subentity, in the first place?
This is what is happening:
- The root collection is fetched (Customer)
- The fetch routine detects that there is a PrefetchPath.
- Fetch the entities of the PrefetchPath. (Order)
- Merge the entities of the prefetchPath (Order) with the root entities (Customer)
- The fetch routine detects that there is a SubPath
- Fetch the entities of the SubPath (Customer, again)
- Merge the entities of the SubPath (Customer) with the root entities (Order).
At this point, the root entity is Order and the prefetchPath entity is Customer (note that this is a new customer instance, different form the customer at step 1). Then this line is reached at OrderEntity.cs:
case "Customer":
this.Customer = (CustomerEntity)entity;
Before this line is reached, this.Customer already have a reference to the original Customer (fetched at step 1), and after that, the customer object is assigned to another instance, the synchronization takes care of Unset the original Customer of the Order, and remove that order from the customer.Order collection as well. That's why you don't see any orders at all.
Also note that in your example, you are fetching the same Customers twice.
The bottom line is Why are you doing this?
Is there any special reason you want to achieve such thing?