如何找到NHibernate的/城堡的ActiveRecord会话对象 [英] How to find object in nHibernate/castle activerecord session

查看:162
本文介绍了如何找到NHibernate的/城堡的ActiveRecord会话对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图更新对象时收到以下错误在一个Asp.Net城堡ActiveRecord的应用程序:

I am getting the following error in an Asp.Net Castle ActiveRecord app when trying to update an object:

具有相同的标识值不同的对象已经与会话相关的

"a different object with the same identifier value was already associated with the session"

我上下打量着我的code,看看那里的其他对象可能已被创建,但我没有看到它。这是令人费解,因为我有一个上的更新工作正常,另一页上完全相同的code

I've looked up and down my code to see where else the object might have been created but I'm not seeing it. This is baffling as I have the exact same code on another page that works fine on updates

现在我想的想看到这个其他对象在会话,要么杀死它或了解它是如何钻进了会议。我如何才能找到这个对象?

Now I'm thinking of trying to see where this other object is in the Session and either kill it or find out how it got into the session. How can I find this object?

[更新]
好吧,我终于找到了对象被调用。不过,我还是想知道如何找到以供将来参考会话对象。

[Update] Ok, I finally found where the object is being called. However, I would still like to know how to find objects in the session for future reference.

推荐答案

如果您需要检查的对象是在会话中你可能做的事情从一开始就走错了路。考虑如何管理您的会话以及持久的对象。

If you need to check if an object is in your session you're probably doing things the wrong way from the start. Reconsider how you manage your session and persistent objects.

这就是说,你可能想尝试 ISession.Contains(),但IIRC如果你使用的检查它只会工作的具体实例的存储在会话

That said, you might want to try ISession.Contains(), but IIRC it will only work if you check with the exact instance that is stored in the session.

这篇关于如何找到NHibernate的/城堡的ActiveRecord会话对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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