Add/Update a list of entities using the entity framework

c# entity-framework silverlight-4.0

Question

I'm returning a List (own class) from Silverlight to a service, in this list there are old entities with updated values and completely new entities, how do I save this back to the database using the entity framework?

Using cEnts.CardItems.AddObject gives me duplicates obviously.

1
3
12/21/2009 3:59:33 AM

Popular Answer

You want to use Attach() instead of AddObject().

Attach will take your disconnect object and let the container know to consider it for updates. The new objects, without a PrimaryKey, will be added.

3
12/21/2009 5:40:15 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow