tags:

views:

68

answers:

2

Say I have an entity that looks as follows

public Order OrderEntity 
{   
   EntityRef<Customer> CustomerEntity;   
   EntitySet<OrderDetail> OrderDetailEntity;   
   ...   
   ...
}

When I save a OrderEntity, L2S, will want to also save the entity in CustomerEntity and all the entities in OrderDetailEntity. Sometimes we want this behavior and sometimes we do not. For those times we do not, how to tell L2S not to do this?

Thanks - Randy

+1  A: 

If there are no changes made to a particular entity, L2S will not do an actual save to the database
when you SubmitChanges(). If there are changes made to a particular entity, and you execute SubmitChanges(), I assume you want them to take effect.

If there are changes to a particular entity, but you don't want them to take effect when
SubmitChanges() is called, then you have to do the work on the entities individually;
i.e. load and save them separately from your larger entity.

http://msdn.microsoft.com/en-us/library/bb399378.aspx

Robert Harvey
A: 

If any of OrderEntity child objects are changed and you don't want to save the changes, i suggest that you reload OrderEntity with non of its child objects, make the changes then save it.

O. Askari