通过传递给 OnFlushDirty 的 DictionaryAdapter 进行枚举
我正在尝试使用 Castle.ActiveRecord
对象的 OnFlushDirty
方法来实现对更改的通用审核:
protected override bool OnFlushDirty(object id,
IDictionary previousState,
IDictionary currentState,
NHibernate.Type.IType[] types
)
执行时,OnFlushDirty 会传递一个 Castle.ActiveRecord .Framework.DictionaryAdapter
用于每个 previousState
和 currentState
参数。
不幸的是,DictionaryAdapter
不支持 GetEnumerator()
方法,会抛出 NotSupportedException
。
- 我应该首先期望将
DictionaryAdapter
传递到 OnFlushDirty 中吗?假设 - 我应该这样做,我如何枚举 DictionaryAdapter 中的键/值对,以便比较以前和当前的状态进行审核?
I am attempting to use the OnFlushDirty
method of a Castle.ActiveRecord
object in order to implement generic auditing of changes:
protected override bool OnFlushDirty(object id,
IDictionary previousState,
IDictionary currentState,
NHibernate.Type.IType[] types
)
On execution, OnFlushDirty is passed a Castle.ActiveRecord.Framework.DictionaryAdapter
for each of the previousState
and currentState
parameters.
Unfortunately DictionaryAdapter
does not support the GetEnumerator()
method, throwing a NotSupportedException
.
- Should I be expecting a
DictionaryAdapter
to be passed into OnFlushDirty in the first place?; and - Assuming I should, how can I enumerate through the Key/Value pairs within the
DictionaryAdapter
in order to compare previous and current states for auditing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DictionaryAdapter
包含一个 Key 集合,可以正常枚举该 Key,然后应用该 Key 来检索其 Value。示例解决方案代码:
The
DictionaryAdapter
includes a Key collection which can be enumerated normally with the Key then being applied to retrieve its Value.Sample solution code: