[英]This isn't returning the same reference when using Castle Proxies with NHibernate
I'm having some trouble where returning "this" is somehow returning a different reference/type when using castle proxies with nhibernate. 在将城堡代理与nhibernate结合使用时,返回“ this”在某种程度上返回不同的引用/类型时遇到了麻烦。 Castle is 2.5.2.0 and NHibernate is 3.1.0.4000 Castle是2.5.2.0,NHibernate是3.1.0.4000
public class Node
{
public int Id { get; set; }
public Node Me() { return this; }
}
public static void SomeMethod()
{
var node = session.Load<Node>(1)
var me = node.Me()
//ReferenceEquals(node, me) // false
//node == me // false
//node.GetType().Name // NodeProxy
//me.GetType().Name // Node
me.Id = 88;
// node.Id == 88 // true
}
This is an expected behavior. 这是预期的行为。 See my blog post, Hacking lazy loaded inheritance . 请参阅我的博客文章hacking延迟加载继承 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.