ordering entity (ObjectGraphUtils ?)

Posts   
 
    
braidiano
User
Posts: 40
Joined: 18-Nov-2006
# Posted on: 24-Sep-2010 12:14:13   

Hi,

I have an i IList<IEntity2> of entities. Is there a way to sort the list, based on Relation dependency.

I explain a little more simple_smile

CustomerEntity OrderEntity OrderDetailEntity

OrderEntity has a relation m : 1 with CustomerEntity OrderDetailEntityhas a relation m : 1 with OrderEntity

in my IList<IEntity2> there are:

index 0: OrderEntity index 1: CustomerEntity index 2: OrderDetailEntity

I want to sort this list based on related entity, that will be:

index 0: OrderDetailEntity index 1: OrderEntity index 2: CustomerEntity

I want to sort the list as LLBL do in save process. I think that this mecchanism is built on ObjectGraphUtils, but this class is not documented.

I need this sorted list for transmit my entities over WCF, properly sorted.

LLBLGenPro 2.6 Adapter

thank you

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 25-Sep-2010 03:51:53   

Hi Davide,

Are the entities in list related to each other? f.i., that customer is referenced by the order and the orderDetail references order.

Why do you need to send them sorted that way?

David Elizondo | LLBLGen Support Team
braidiano
User
Posts: 40
Joined: 18-Nov-2006
# Posted on: 25-Sep-2010 14:00:59   

daelmo wrote:

Hi Davide,

Are the entities in list related to each other? f.i., that customer is referenced by the order and the orderDetail references order.

Yes, the entities are related.

daelmo wrote:

Why do you need to send them sorted that way?

because it is a kind of sync and replication system for disconnected data, so when on other side f.i. I receive on OrderEntity, I need know that other related data has been sent previously, so i can perform saving, updating, etc..

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 26-Sep-2010 13:57:29   

You said you have a IList<IEntity2>, how you end up with that? Do you have the root entity/collection with all graph. For example, you have the customer, and its customer.Order, so on?

If so, I think you can do this:

ObjectGraphUtils ogu = new ObjectGraphUtils();
List<IEntity2> orderedList = ogu.ProduceTopologyOrderedList(customer);
orderedList.Reverse();
David Elizondo | LLBLGen Support Team