views:

7

answers:

0

Hi All,

I’m using Silverlight4 and Ria Service :

Imaging we have a table (called "MyTable") with 3 records ( 1 , 2 , 3 ) , I’ve just written the following codes somewhere in my application:

CurrentItem  = 1;
MyContext.MyTables.Delete(CurrentItem);
CurrentItem  = 2;
MyContext.MyTables.Delete(CurrentItem);

For some reasons, before hitting The “Save” Button, I want to reject the first deleted item(1) but still want to delete the second one(2) .it means that I can’t use :

MyContext.RejectChanges()  

Because It will reject all changes (including the deleted item which what I do want to delete it) so I though, using IRevertibleChangeTracking can solve my issue .Something like this :

((IRevertibleChangeTracking) MyItem).RejectChanges();

But before using this Interface, I have to access the deleted Item. At first, It tried to get it via MyContext.MyTables but it doesn’t contain deleted records so I tried to obtain it by EntityChangeSet:

EntityChangeSet Changes =  MyContext.EntityContainer.GetChanges();
MyTable  DeletedItem  = Changes.First<MyTables>( e => e.ID = 1 ) ;

And then I used IRevertibleChangeTracking:

((IRevertibleChangeTracking) DeletedItem  ).RejectChanges();

But after Running, This line of code didn’t change the state of the record and it was kept as “Deleted” so by hitting the “Save” Button, It was deleted from the Database Physically !!!! It seems IRevertibleChangeTracking doesn’t work for deleted/Added items ( it just works for modifed Items ).

So ,Is there any way to reject a particular deleted item from the DomainContext.

Thanks,