如何检测NHibernate中的集合更改 [英] How to detect collection changes in NHibernate

查看:101
本文介绍了如何检测NHibernate中的集合更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检测NHibernate中许多集合和列表的更改(添加和删除)?

How can I detect changes (additions and removals) from many to many sets and lists in NHibernate?

我使用拦截器来检测对象中的更改模型(用于审计等),这对于对象内的更改(使用OnSave / OnFlushDirty)非常有效,但不适用于集合。

I'm using an interceptor to detect changes in the object model (for auditing and more), this works great for changes within object (using OnSave/OnFlushDirty) but not for collections.

当集合更改时,调用OnCollectionUpdate方法但它只接收持有集合和集合的最新项目的对象的键。

When a collection changes the OnCollectionUpdate method is called but it only receives the key of the object holding the collection and the collection's latest items.

我需要的是:


  1. 保存集合的对象(或至少键入+键,键在我的系统中的类中是唯一的)我现在只有键。

  1. the object holding the collection (or at least type+key, the key is only unique within a class in my system) I only have the key now.

集合的属性名称(我拥有多个集合的类别)

the property name of the collection (I have classes with multiple collections)



。添加项目列表以及已移除项目列表(或者当前事务之前和之后的收集内容)

有任何方法可以获得这些信息吗?

Is there any way to get to this information?

推荐答案

也许有点棘手,代理?

这篇关于如何检测NHibernate中的集合更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆