New Posts New Posts RSS Feed: Undo Delete
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Undo Delete

 Post Reply Post Reply
Author
cjohnson84 View Drop Down
Groupie
Groupie


Joined: 24-Sep-2009
Location: Akron, Ohio
Posts: 44
Post Options Post Options   Quote cjohnson84 Quote  Post ReplyReply Direct Link To This Post Topic: Undo Delete
    Posted: 08-Jul-2010 at 12:10pm
I have an observable collection that is bound to a datagrid.  I have a templated column that contains a "Delete" button for each row.  When the user clicks the "Delete" button for a specific row the entity is "marked" for deletion.  Programmatically I do this with the following line:
 
entity.EntityAspect.Delete();
 
Eventually when the user clicks a "Save" button the entity is truly deleted from the database.
 
My question is, once a row in the datagrid is marked for deletion I would like to be able to allow the user to click the "Delete" button again to "undo" the delete operation.
 
How do I achieve this?
 
I was looking at
 
entity.EntityAspect.AcceptChanges()
 
this sets the state of the entity to "Detached" though...I want set the state of the entity back to "Unchanged" as if it was never touched at all but EntityState is read only.
Back to Top
smi-mark View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 24-Feb-2009
Location: Dallas, Texas
Posts: 343
Post Options Post Options   Quote smi-mark Quote  Post ReplyReply Direct Link To This Post Posted: 08-Jul-2010 at 12:21pm
entity.EntityAspect.RejectChanges()
Back to Top
Robert R View Drop Down
Newbie
Newbie


Joined: 17-Aug-2010
Posts: 7
Post Options Post Options   Quote Robert R Quote  Post ReplyReply Direct Link To This Post Posted: 04-Nov-2010 at 8:40am
Is there any way to undo only the deletion without rejecting all changes to the entity?
 
I have a situation similar to the original post.  If the user made changes to properties of the entity, but then deletes it and then undeletes it, I would like those property changes to still be in effect.
 
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 04-Nov-2010 at 10:23am
Hi,
 
You could AcceptChanges before Delete'ing the entity. Later, if you need to undelete the entity, you would use SetModified.
 
A drawback is that, if you undelete, once you SaveChanges, that entity will be "resaved". (i.e. travel accross the wire)
 
 
I hope this helps.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down