5

I'm having the following issue with WCF RIA Services: I have a table Customer and a table Address. A customer can have 0...n addresses. There is a form for editing the customer, with a Datagrid that displays the addresses. You add / edit an address in a child window by clicking Add / Edit. Now here's the thing:

The problem is that the user should always be able to cancel edits. This is not a problem except: If you create a new customer and you add an address to that customer, then want to edit the address but want to cancel that edit.

  • You can't do RejectChanges to the context, because it would erase the address with the customer.
  • You can't use seperate contexts because then you can't establish the foreign key relation.

How would you guys solve that?

LueTm
  • 2,366
  • 21
  • 31

2 Answers2

6

Entity implements IRevertibleChangeTracking to support this scenario. Since it's implemented explicitly, you'll have to cast it. The following code will work.

((IRevertibleChangeTracking)address).RejectChanges();
Kyle McClellan
  • 2,019
  • 1
  • 13
  • 8
0

It's working in case of edit but not in case of new..

Sajid Ali
  • 719
  • 2
  • 7
  • 21