问题
I am building a .NET application for inserting data (an Excel add-in in fact), and I want to use an ORM for inserting data with automated versioning.
Here's a worked example:
- User "John Doe" does the first data insertion (4 data points as per below example)
- At a later time, user "Albert" opens the interface, modifies one data point, and saves
- All 4 data points are processed; ORM flags the modified data as non-Current, adds the new data, updates version counter, changes validity dates columns
I am looking for an ORM framework that would automatically take care of the versioning. Below, the database table after the second insertion. Those familiar with DB schemas will recognize this as a "Slowly Changing Dimension (SCD) Type 2"
The data will be accessed not via the ORM, but from various SQL queries, so the valid_from/valid_to columns are essentials. I am also aware that this can be done with database triggers but I want a solution that works regardless of back-end...
回答1:
Finally found something.
NHibernate has a versioning extension, Envers.
http://www.primordialcode.com/blog/post/nhibernate-envers-quick-introduction
It will create both last-version tables and versioned tables. It won't call it a "Slowly Changing Dimension", but the versioning strategy is equivalent (as opposed to creating a table for each measure to version)
Schema below.
来源:https://stackoverflow.com/questions/61372560/net-orm-framework-with-data-versioning-slowly-changing-dimension-type-2