简体   繁体   English

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

[英]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.

相关问题 使用城堡ActiveRecord,当两个类具有相同的名称但名称空间不同时,我得到了NHibernate DuplicateMappingException - Using Castle ActiveRecord, I get an NHibernate DuplicateMappingException when two classes have the same name but different namespaces 使用NHibernate插入或保存时为Object Proxies提供什么值 - What value to give for Object Proxies when Inserting or Saving using NHibernate 使用ReferencesAny时如何配置Fluent NHibernate以返回空值而不是丢失对象的代理 - How to configure Fluent NHibernate to return null instead of proxies for missing objects when using ReferencesAny 对代码和 NHibernate QueryOver 使用相同的规范<t></t> - Using same specification for code and NHibernate QueryOver<T> NHibernate交易不是孤立的 - NHibernate transaction isn't isolated Castle Windsor:当我的装配无法访问基础类型时,如何注册工厂方法? - Castle Windsor: How do I register a factory method, when the underlying type isn't accessible to my assembly? NHibernate,代理和平等 - NHibernate, proxies and equality 在没有默认构造函数的情况下返回Castle DynamicProxy对象时,SignalR hub调用不起作用 - SignalR hub invoke doesn't work when returning a Castle DynamicProxy object without a default constructor 什么是使用Castle Active Record和Straight NHibernate的利弊? - Whats the pros and cons of using Castle Active Record vs Straight NHibernate? 与 Autofac 并行运行 xUnit 集成测试时无法加载类型 Castle.Proxies.IReadinessProxy - Could not load type Castle.Proxies.IReadinessProxy when running xUnit integration tests in parallel with Autofac
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM