Walaa wrote:
Please try the following:
EntityA a = new EntityA();
a.Id = 3;
adapter.FetchEntity(a);
// And later on fetch related EntityBs:
adapter.FetchEntityCollection(a.bs, a.GetRelationInfoEntityBs, ...);
In the meantime, I have done some homework, and checked that:
-
A simple FetchEntityCollection(bs, ...) (i.e. on a new collection) does not load bs[i].EntityA.
-
Adding a prefetch path does load bs[i].EntityA but bs[i].EntityA != a, and it will use two queries.
-
Adding a context and no prefetch path does not load bs[i].EntityA.
-
Adding a context and a prefetch path does load bs[i].EntityA, and we have bs[i].EntityA == a,
but it uses two queries (i.e. it tries to refresh a anyway).
What you propose does what I want. Many thanks!
I did not think about it because, in my mind, I was trying not to modify the EntityA, or planning for the case where a.bs would be hidden (i.e. the relation exists but EntityA does not expose it as a field).
Would there be a solution in that case?