如何确定 NHibernate 实体是否已更新
我有一个基于外部数据批量更新大量实体的应用程序。其中一些不会改变。当我调用 DbContext.CommitChanges() 时,NHibernate 足够聪明,可以知道实体是否已更改以及是否发送更新。
但我希望能够在实体更新时输出到屏幕/日志。
如何查明是否已执行更新?如何连接 Nhibernate 变更跟踪?
I have an application that mass-updated a load of entities based on external data. Some of them will have not changed. NHibernate is clever enough to know whether the entity has changed and whether or not to send an update when I call DbContext.CommitChanges()
.
But I want to be able to output to screen/log when an entity has been updated.
How do I find out if an update has been executed? How do I hook into Nhibernate change tracking?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NHibernate 有一个可以连接的事件系统。这是一篇博客文章,解释了您想要执行的操作:
NHibernate 2.0 事件和侦听器
以下是 NHibernate 教程中解释事件系统的部分:
第 11 章拦截器和事件
还有一个:
使用 NHibernate 事件创建审核日志
NHibernate has an event system you can hook up to. Here is a blog post that explains what you want to do:
NHibernate 2.0 Events and Listeners
Here is the part of the NHibernate tutorial that explains the event system:
Chapter 11. Interceptors and events
And another one:
Creating an Audit Log using NHibernate Events