Is there a way using SS and Ormlite to automatically audit data changes?
You can use a ProfiledDbConnection to monitor for all queries:
Logging on the dataset level requires dataset level intervention. There are tools available for a number of databases like SQL Server and PostgreSQL.
Why would you want to monitor all changes in Ormlite?
Not to exclusively monitor more so to track changes for auditing purposes like in this EF extension http://entityframework-plus.net/audit
There’s nothing built in OrmLite but you may be able to use the Insert/Update filters, although you would need to use a new db
connection instead for new queries instead of using the injected dbCmd
.
Although the cleaner, more flexible solution would be to create your own custom OrmLite extension methods which does what you want so instead of calling db.Insert()
call a custom extension method like db.InsertWithAudit()
which does what you want.
Where can we look for a sample of extensions.
I have a similar need. For syncing data between 2 databases
I mean just wrap your custom functionality behind a standard c# extension method, all of OrmLites APIs are just extension methods on ADO.NETs IDbConnection Interface, so instead of calling it directly call your own extension method which does what you need.
Keep in mind that that will only audit changes made through the actual program/service. I was hinting on database changes (which should be handled on the database level).