简体   繁体   English

使用Nhibernate维护表历史记录

[英]Maintain Table History with Nhibernate

I have a situation where I have to maintain History of a table. 我必须维护表的历史记录。

For Eg: I have PaymentTransaction Table and I want to keep PaymentTransactionHistory for auditing purposes. 例如:我有PaymentTransaction表,并且我想保留PaymentTransactionHistory以便进行审核。

Do we have anything in NHIbernate that can be used to achieve this. 我们在NHIbernate中有什么可以用来实现这一目标的。 I read about IInterceptor and Events and couldn't really understand if they could be of any use in my case. 我读了有关IInterceptor和Events的文章,但我真的不明白它们是否对我有用。

I am using Fluent NHIbernate. 我正在使用Fluent NHIbernate。

Many Thanks 非常感谢

NHibernate Envers也可能是您的选择-但可能对您提到的用法有些过高

In my project this is done by an interceptor, using following methods: 在我的项目中,这是由拦截器使用以下方法完成的:

  • When something got deleted, process it in OnDelete 删除某些内容后,请在OnDelete中对其进行处理
  • When something inserted into DB, process it in OnSave 将某些内容插入数据库后,请在OnSave中对其进行处理
  • When something changes, process it in OnFlushDirty 发生更改时,请在OnFlushDirty中对其进行处理
  • There are some other methods for handling collection. 还有其他一些方法来处理收集。

Just try them, it's not difficult. 只需尝试一下,这并不困难。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM