Detaching a related entity / collection

Posts   
 
    
stefcl
User
Posts: 210
Joined: 23-Jun-2007
# Posted on: 02-Dec-2007 16:48:41   

Hello,

I'd need to detach a related entity or collection from an entity but WITHOUT altering foreign keys, I would just like to break the link between them.

Here's the problem : when fetching a collection of orderDetailEntities from the main server, I use prefetch path to fetch their related productEntities. When the user finishes editing the orderDetails, the modified collection is sent back to the server by using .net remoting.

My problem is that the related productEntities will be sent at the same time as the orderDetailEntities, it's totally useless in my case because the server already knows about the products, it only needs the ProductID field from an OrderDetailEntity, not the product itself.

Is there some way I could remove the productEntity from the orderDetailEntity without reseting the orderDetailEntity.ProductID field?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Dec-2007 21:31:37   

While you can use some tricks with Context object and ObjectGraphUtils, the easiest way is iterate trough your OrderDetail collection and set the Product property to null. The FK field will remain the same.

David Elizondo | LLBLGen Support Team