"Safe" Deletion of Entities

Posts   
 
    
peschkaj
User
Posts: 30
Joined: 21-Sep-2006
# Posted on: 27-Sep-2006 14:33:15   

Rather than outright deleting entities from the database, I would like to set a DeletedBy and DeletionDate in the database so that users will be able to, effectively, undelete information if they need to.

What would be the best way to accomplish this?

My current thought is to override the DeleteEntityCollection, DeleteEntity, and DeleteEntitiesDirectly methods to set the DeletedBy and DeletionDate fields and then call SaveEntity rather than DeleteEntity.

Is there a better/easier way to accomplish this within LLBLGen?

Thanks,

Jeremiah

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 27-Sep-2006 15:00:54   

I can't think of a better way within LLBLGen Pro. But I'd have made these into the BL if one exists. I mean I would modify my Delete methods which was calling the LLBLGen Pro Delete methods, to Update the entities with the needed info.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 27-Sep-2006 15:43:06   

I've to seriously reconsider the use of soft-deletes (as these are called) and to not use them. The working set you'll work with is, over time, much smaller than the real # of rows in the db, which has issues on its own.

You should implement a delete trigger which copies the rows to an archive table, and an undelete should simply re-insert the entities. You can also circumvent this in the GUI, as deleting information is often not necessary, and IF people want to delete information, it is REALLY GONE. Why not simply leave the data there? And if you want to get rid of it, because it pollutes the workingset, ARCHIVE it. Because that's what you want: you want to delete the info, but in case some moron hits delete accidently and you want to get it back, it's not completely gone.

Repaving my windows partition also wipes everything clean, there's no undo option once I've formatted an fdisk-ed hdd.

Frans Bouma | Lead developer LLBLGen Pro