NHibernate.ActsAsVersioned
0.3.0
dotnet add package NHibernate.ActsAsVersioned --version 0.3.0
NuGet\Install-Package NHibernate.ActsAsVersioned -Version 0.3.0
<PackageReference Include="NHibernate.ActsAsVersioned" Version="0.3.0" />
paket add NHibernate.ActsAsVersioned --version 0.3.0
#r "nuget: NHibernate.ActsAsVersioned, 0.3.0"
// Install NHibernate.ActsAsVersioned as a Cake Addin #addin nuget:?package=NHibernate.ActsAsVersioned&version=0.3.0 // Install NHibernate.ActsAsVersioned as a Cake Tool #tool nuget:?package=NHibernate.ActsAsVersioned&version=0.3.0
NHibernate.ActsAsVersioned
This project aims to enable auditing of persistent classes in a form compatible with the acts_as_versioned rubygem for ActiveRecord.
The feature set is very limited. The main purpose of this package is to provide compatibility
with an existing Ruby on Rails code base that makes use of acts_as_versioned
. If you are
looking for a more sophisticated auditing solution for NHibernate, checkout
NHibernate Envers.
Usage
This description assumes that the reader is familiar with setting up NHibernate.
Step 1 Reference the NHibernate.ActsAsVersioned
assembly in your project.
Step 2 Enable the acts as versioned functionality during program initialization, when the NHibernate Configuration
object is created.
// Create configuration using XML mappings, mapping by code, Fluent NHibernate, etc
Configuration cfg = BuildConfigurationSomehow();
// Enable ActsAsVersioned
cfg.IntegrateWithActsAsVersioned();
// Now ready to build a session factory
var sessionFactory = cfg.BuildSessionFactory();
The IntegrateWithActsAsVersioned()
extension method is provided by the NHibernate.ActsAsVersioned
assembly,
and is located in the NHibernate.Cfg
namespace for convenience.
Step 3 To mark an entity class as being versioned, use the [ActsAsVersioned]
attribute. All persistent properties
of the entity will be versioned unless the property has been annotated with a [NotVersioned]
attribute.
[ActsAsVersioned("book_versions")]
public class Book {
public virtual int Id { get; set; }
public virtual string Title { get; set; }
public virtual Author Author { get; set; }
[NotVersioned]
public virtual string ScratchPad { get; set; }
}
The [ActsAsVersioned]
attribute requires you to specify the table name for the version table. By convention
this table name is {{entity}}_versions
. This goes against the Ruby on Rails convention of figuring names out
for itself, but at least for now the requirement to specify the table name eliminates the need for complicated
inflection algorithms.
Limitations
This project was initiated for the purpose of providing compatibility with an existing Ruby on Rails application. Only features that are required for that application have been implemented.
Features not supported:
- Abstract classes
- Subclasses
- Composite keys
Other limitations:
- The
acts_as_versioned
rubygem requires aversion
column. This implementation assumes that the class being tracked for changes has alock_version
column, and this is used in place of the version column. It would be simple enough to add a version column, but it has not been necessary to date.
License
Because this project depends on NHibernate, and was written after inspecting the NHibernate.Envers repository, this project is licensed using the LGPL.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- NHibernate (>= 5.3.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Add AutoUpdate attribute