I'm working on a .Net project using Dapper as the ORM. EF is not really an option as we need the DB/schema to be somewhat flexible at runtime.
Using Dapper.Contrib we can use the 'change tracking' feature to optimise what gets written to the database. What we'd really like is to be able to access this information (what's changed) and write it to a 'change history' log.
There doesn't seem to be a lot of documentation in Dapper.Contrib about this. Has anybody got any suggestions on how this could be done? Thanks.
Ok it looks like the Dapper.Contrib 'change tracking' is just an efficiency helper (it only writes SQL for actual changes). I've used reflection to pre-load the model structure during startup, then used that to check for changes between my two versions of model.
If it helps anyone, the code looks something like this (be aware testProps is the reflected list of class properties, DifferenceCompare is a simple model for tracking changes):
Credit to Oskar Kjellin for the starting point of this.