How to do this (fetchentitycollection)

Posts   
 
    
riclo
User
Posts: 7
Joined: 13-Aug-2010
# Posted on: 04-Nov-2010 15:30:16   

Consider this:

customer-orders-ordertype all related to each other:

How can i fetch this the best way to get : 1 customer - several orders - 1 ordertype per order

I just came to the following

adapter.fetchentitycollection(orders,customer.GetRelationInfoOrders())

How do I get the ordertype

Richard

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 04-Nov-2010 21:08:43   

You need to "get" the difference between relations and pre-fetch paths. Pre-fetch paths are for fetching graphs of related entites (this is what you are trying to do). Relations are for adding additional tables in to the query to allow you to filter on data in related tables (effectivly they generate SQL joins)

You need something like


var pfp = new PreFetchPath2();
pfp.Add(CustomerEntity.PrefetchPathOrders).SubType.Add(OrderEntity.PrefetchPathOrderType);
adapter.FetchEntityCollection(customers,pfp) //check correct overload...!




Matt

riclo
User
Posts: 7
Joined: 13-Aug-2010
# Posted on: 05-Nov-2010 14:54:00   

Thanks, Matt