Getting parent entity from related EntityCollection

Posts   
 
    
sg_mt
User
Posts: 4
Joined: 22-Jun-2009
# Posted on: 28-Jun-2009 20:20:59   

Simple question:

I have three tables

A.ID 1-oo B.AID C.ID 1-oo B.CID

Entity of A has property BsCollection which I can fetch by

 using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                adapter.FetchEntityCollection(a.BsCollection, a.GetRelationInfoBsCollection());
}

After that fetch I have a collection of B's and each [b] in this collection has property C (should contain entity of C). How to fetch enitity of C? Intellisense LLBLGen generated comments tells me, that C should be fetched before fetching B.

I understand that I can fetch this entity by various methods, i.e.

C c = new C(b.CID); 
                            adapter.FetchEntity(c); 
b.C = c;

or

EntityCollection<C> Cs = new EntityCollection<C>();
                            adapter.FetchEntityCollection(Cs, b.GetRelationInfoC());
                            b.C = Cs[0];

but these are my combinations rather then out-of-the-box oneline solution.

So, how I could fetch a parent entity using relations info and not fetching entity collection? Or maybe LLBLGen does not differentiate between 1-n and n-1 relation in this scenario?

Regards, Jack

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 29-Jun-2009 08:14:30   

Hi Jack,

You should use PrefetchPaths. Please take a look. If you have troubles, let us know.

David Elizondo | LLBLGen Support Team