Back to articles
Automatic audit trails and soft delete in Delphi with Trysil
NewsTools

Automatic audit trails and soft delete in Delphi with Trysil

via Dev.toDavid Lastrucci

Most ORMs handle INSERT, UPDATE, and DELETE well. But when you need to track who changed a record and when , or keep deleted records around instead of erasing them, you're usually on your own — writing triggers, adding boilerplate to every repository method, or bolting on an external audit library. In Trysil (an open-source ORM for Delphi), I wanted these features to be declarative: add an attribute, and the framework handles the rest. No base class to inherit, no interface to implement, no code to write beyond the attribute itself. This article shows how it works. The problem Consider a typical entity: [ TTable ( 'Invoices' )] [ TSequence ( 'InvoicesID' )] TInvoice = class strict private [ TPrimaryKey ] [ TColumn ( 'ID' )] FID : TTPrimaryKey ; [ TColumn ( 'InvoiceNumber' )] FInvoiceNumber : String ; [ TColumn ( 'Amount' )] FAmount : Double ; [ TVersionColumn ] [ TColumn ( 'VersionID' )] FVersionID : TTVersion ; public property ID : TTPrimaryKey read FID ; property InvoiceNumber : Stri

Continue reading on Dev.to

Opens in a new tab

Read Full Article
2 views

Related Articles