c# - Fluent NHibernate Reveal 不使用给定的属性名

标签 c# nhibernate fluent-nhibernate fluent-nhibernate-mapping

我正在尝试在我的类中映射以下 protected 集合:

public class AddressList
{
    protected readonly IList<Address> addresses = new List<Address>();
}

具有以下映射:

HasMany<Address>(list => Reveal.Member<AddressList>("addresses"));

但我不断收到 NHibernate.MappingException

NHibernate.MappingException : Could not compile the mapping document: 
(XmlDocument) > NHibernate.PropertyNotFoundException 
: Could not find a getter for property '**Member**' in class

但是正如您在 Reveal.Member 中看到的那样,我声明它应该查找的属性名称应该是“地址”

我找到了this问题,用户似乎和我有同样的问题,只是这是一个老问题

我也尝试过给出的解决方案 here

最佳答案

您不应将 lambda 表达式与 Reveal 一起使用

正如您在异常消息中看到的:

NHibernate.MappingException : Could not compile the mapping document: (XmlDocument) > NHibernate.PropertyNotFoundException : Could not find a getter for property 'Member' in class

我尝试映射到名为 Member 的字段当您使用list => Reveal.Member时而不仅仅是Reveal.Member

关于c# - Fluent NHibernate Reveal 不使用给定的属性名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14400368/

相关文章:

c# - 如何在 Fluent nHibernate 中对 HasMany 映射进行额外过滤?

mysql - 如何在 MySql 数据库中使用 guid.comb 策略

c# - 为什么我的 Equals 方法没有被调用?

c# - dnx 在 Visual Studio Code 上运行 C# 控制台应用程序

c# - NHibernate 代理导致数据绑定(bind)问题

c# - 与 NHibernate 的一对一映射/使用实体作为 PK

fluent-nhibernate - 在 Fluent Nhibernate 中禁用特定覆盖的缓存

c# - 如何在 App.Config 中写入 URI 字符串

c# - MVC5 与函数和过程的 EF6 存储库模式实现

c# - 发生异常后不刷新 session