Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLBLGen: How can I softdelete a entry

Tags:

c#

llblgenpro

I have inherited a project that uses LLBLGen Pro for the DB layer. The DB model requires that when a entry is deleted a flag (DeletedDate is set to the current time). The last programmer ignored this requirement and has used regular deletes throughout the entire application.

Is there a way to set the code generator to do this automatically or do I have to overload each delete operator for the Entities that requires it?

like image 524
AdamSane Avatar asked Sep 25 '08 12:09

AdamSane


2 Answers

I implemented this in SQL Server 2005 using INSTEAD OF triggers on delete for any soft delete table. The triggers set the delete flag and perform clean-up. The beauty of this solution is that it correctly handles deletes issued by any system that accesses the database. INSTEAD OF is relatively new in SQL Server, I know there's an Oracle equivalent.

This solution also plays nicely with our O/R mapper -- I created views that filter out soft deleted records and mapped those. The views are also used for all reporting.

like image 94
Jamie Ide Avatar answered Oct 20 '22 15:10

Jamie Ide


You could create custom task in LLBLGen that would override those for you when you are generating entities. Check out their template studio and template examples on the website.

like image 2
Slav Avatar answered Oct 20 '22 15:10

Slav