RejectChanges for specific objects

I had the following problem with WCF RIA services: I have a Client table and an Address table . A client can have 0 ... n addresses. There is a form for editing a client, with a Datagrid that displays addresses. You add / edit the address in the child window by clicking the "Add / Edit" button. Now here is what:

The problem is that the user should always be able to discard the changes. This is not a problem except . If you create a new client and add the address to this client, you want to edit the address, but want to change the cancel .

  • You cannot execute RejectChanges in context because it will delete the address with the client.
  • You cannot use separate contexts because then you cannot establish the relation of a foreign key.

How do you guys solve this?

+5
source share
2 answers

Entity implements IRevertibleChangeTracking to support this scenario. Since it is implemented explicitly, you will have to drop it. The following code will work.

((IRevertibleChangeTracking)address).RejectChanges();
+6
source

It works in case of editing, but not in case of new.

0
source

All Articles