繁体   English   中英

在将Castle Proxies与NHibernate结合使用时,这不会返回相同的参考

[英]This isn't returning the same reference when using Castle Proxies with NHibernate

在将城堡代理与nhibernate结合使用时,返回“ this”在某种程度上返回不同的引用/类型时遇到了麻烦。 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
}

这是预期的行为。 请参阅我的博客文章hacking延迟加载继承

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM