Retrieving a tree of entities

Posts   
 
    
Walter Almeida avatar
Posts: 150
Joined: 27-Aug-2007
# Posted on: 07-Oct-2010 10:01:37   

Is there an "easy" way to retrieve a full tree of entities.That is: let say I want to retrieve a customer and all the entities directly or indirectly linked to this customer, like orders, orderdetails, products etc. (adapter mode)

I mean a way without having to create prefetchpaths (that could become cumbersome in case of complex entity trees) + have to be maintained when DB evolves

I understand this a tricky scenario that could lead to querying the full database but could be used in controlled cases. Maybe a "level" option limiting the level to which this "automatic prefetch" would go.

Thanks in advance

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Oct-2010 10:10:20   

Why not using prefetchPaths?

Is it to save time of writing/coding down these paths? or is it because you need to use this in cases you don't know in advance the entity you are going to pull from the database?

Walter Almeida avatar
Posts: 150
Joined: 27-Aug-2007
# Posted on: 07-Oct-2010 10:22:46   

Walaa wrote:

Why not using prefetchPaths?

Is it to save time of writing/coding down these paths? or is it because you need to use this in cases you don't know in advance the entity you are going to pull from the database?

Let's say it is a very special case where I need to retrieve the full database tree from a starting entity. writing down manually the tree would be cumbersome because of the number of levels involved. And : the database schema evolves rapidly : so maintaining the manually coded tree would be even more cumbersome. So I am looking for a way to do it automatically : specify starting entity, and it does automatically for you the prefetch path down to a certain level.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Oct-2010 10:56:31   

There is no built-in functionality for this, but you can code it yourself.

Are you using SelfServicing or Adapter?

My theory is: you may use SelfServicing to get the benefit of LazyLoading. And then you'll have to write a recursive function that explores the properties of an entity and and dig deep on properties of Type IEntity or IEntityCollection.

Walter Almeida avatar
Posts: 150
Joined: 27-Aug-2007
# Posted on: 07-Oct-2010 11:19:29   

Walaa wrote:

There is no built-in functionality for this, but you can code it yourself.

Are you using SelfServicing or Adapter?

My theory is: you may use SelfServicing to get the benefit of LazyLoading. And then you'll have to write a recursive function that explores the properties of an entity and and dig deep on properties of Type IEntity or IEntityCollection.

Ok, thanks for your feedback, I'll see what I can do by coding myself. I am using the adapter templates by the way