【问题标题】:Private property mapping with fluent nhibernate使用流利的 nhibernate 进行私有属性映射
【发布时间】:2010-11-06 21:33:10
【问题描述】:

我在映射私有属性时遇到异常。情况如下: 我在 Entity.cs 中有这个: privat int m_Inactive;

在 EntityMap.cs 我有:

Map(x => Reveal.Property<Entity>("m_Inactive")).ColumnName.("INACTIVE"); 

但我收到此错误:

System.Reflection.TargetInvocationException: Exception has been thrown 
by 
the target of an invocation. --->  System.ArgumentException: Not a member access 

可能是什么原因?

谢谢。

【问题讨论】:

    标签: fluent-nhibernate fluent


    【解决方案1】:

    如果您关注examples on the wiki,您会发现您应该使用Map(Reveal.Member&lt;YourEntity&gt;("m_Inactive"))

    【讨论】:

    【解决方案2】:

    看起来在最新版本中您应该使用 Reveal.Member,因为 Reveal.Property 已过时:

    Map(Reveal.Member<YourEntity>("m_Inactive"))
    

    哦,有点“废话”,但您需要确保包含 FluentNHibernate:

    using FluentNHibernate;
    

    还有另一个“duh”,但这将适用于受保护成员以及私人

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-28
      • 2011-06-18
      • 2010-12-26
      • 1970-01-01
      相关资源
      最近更新 更多