1
votes

I have a client silverlight application that use RIA service to connect to database Instead of EntitySet to manage entities I have a local cache of data that contain a list of all loaded entities and my context is always empty, this allow me to create multiple queries with multiple logical views into same database table and a better refresh(support remove and handle server triggers for changes).

Now my problem is when an entity change and I want to attach it to EntitySet and submit those changes to the server, Attach function attach object as unmodified.

So my question is how can I attach an entity as modified in the client side of a RIA service. I know how to do it in the server side but I need to do it in the silverlight

2
Why don´t you attach the entity first and then make your modifications? That should change the entity to ModifiedJehof

2 Answers

0
votes

From the context - use the .Attach - method. This will "attach" an entity back to a context allowing the context to track changes to the entity. When you issue a save command, the context execute the appropriate command to CRUD the entity on the server.

Try attaching the entity first, then setting the EntityState as Modified.

Yes - I should have read the whole question before answering! :)

0
votes

You could try to use the IEditableObject interface of the Entity class to solve your problem. The interface is implemented explicitly on Entity, so you have to cast the instance to the interface.

MyEntity entity = new MyEntity();
MyEntitySet.Attach(entity);

((IEditableObject)entity).BeginEdit();
// edit the properties of the entity;
((IEditableObject)entity).EndEdit();