Override Delete?

Posts   
 
    
edalzell
User
Posts: 44
Joined: 27-May-2008
# Posted on: 03-Sep-2008 23:22:40   

Instead of actually deleting entities, we want to flag them as deleted (we have our own flag).

Is there a method to catch all the deletes so I can set the flag instead of deleting the data?

Thanks

edalzell
User
Posts: 44
Joined: 27-May-2008
# Posted on: 04-Sep-2008 01:05:51   

OK, I found OnValidateEntityBeforeDelete, but I'm not sure it will be enough.

To be more descriptive...I still want LLBLGen to think that the delete went through, but instead of actually deleting anything I set a flag to true.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 04-Sep-2008 06:05:51   

Soft deletes aren't supported by default, which means you have to implement it yourself. If you're using adapter, override DeleteEntity() in a subclass of DataAccessAdapter and instead set a Deleted flag and save the entity, in selfservicing, you override the DeleteEntity method in the subclass for the entity in 2-class scenario and do the same thing.

For loading a set of entities, that's a different story. You have to append the filter for deleted entities manually.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 04-Sep-2008 12:22:21   

Soft deletes aren't really that great. What people want is to preserve data and not delete it, however at the same time they don't want that 'deleted' data present in the active workset. If you use deleted flags, your database will become bigger and bigger, but your workset will stay the same, which can degrade performance over time.

So instead, use delete triggers with an archived catalog. In the delete trigger you simply insert the row deleted into an archive table in the catalog for the archived data

This means that your database is as big as your working set, and you still don't lose any data. simple_smile

Frans Bouma | Lead developer LLBLGen Pro