Soft Deletes? - i.e. Flag Record as "Deleted" using Bit field

Posts   
 
    
mshe
User
Posts: 167
Joined: 02-Feb-2006
# Posted on: 03-Feb-2006 05:59:06   

Hi, does the current version of LLBLGen support soft deletes? I have a couple tables I like to flag records rather than physcially delete them.

If not... how have other people handled such types of deletes?

Thanks!

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 03-Feb-2006 06:42:29   

I used to Update the Entity on my Delete Logic, rather than Deleteing it.

MyEntity myentity = new MyEntity(id);
myentity.isDeleted = true;
return adapter.SaveEntity(myentity);// rather than calling adapter.DeleteEntity(myentity);
mshe
User
Posts: 167
Joined: 02-Feb-2006
# Posted on: 03-Feb-2006 07:16:29   

Ah, so your BLL would check for the deleted flag rather than delete it out right?

But what about in the case you're flagging the parent for deletion in a child class?

How did you ensure the soft delete would be enforced at all times?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 03-Feb-2006 07:36:45   

isDeleted is meant to be your Flag (not LLBLGen Pro code) I should have named it MyDirtyFlag simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39930
Joined: 17-Aug-2003
# Posted on: 03-Feb-2006 10:59:32   

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.

Frans Bouma | Lead developer LLBLGen Pro