找不到组件成员的 getter
我们正在使用 Fluent Nhibernate,但我似乎无法映射组件。我的组件类不是实体,并且有两个值:
public class Member
{
public int ID;
public string Name;
}
父实体映射到具有两列的视图以填充两个属性。我使用 Linq 将类映射为组件:
Component(x => x.CurrentMember, m =>
{
m.Map(x => x.ID, "MemberId");
m.Map(x => x.Name, "MemberName");
});
当我运行此命令时,我在构建 SessionFactory 时遇到 FluentNHibernateConfigurationException:“无法在类“Member”中找到属性“ID”的 getter”。这不是一个实体,所以我对我错过了什么感到有点困惑?
We're using Fluent Nhibernate and I can't seem to map a component. My component class isn't an entity and has two values:
public class Member
{
public int ID;
public string Name;
}
The parent entity is mapped to a view with two columns to fill the two properties. I map the class as a component using Linq as:
Component(x => x.CurrentMember, m =>
{
m.Map(x => x.ID, "MemberId");
m.Map(x => x.Name, "MemberName");
});
When I run this I get FluentNHibernateConfigurationException building the SessionFactory: "Could not find a getter for property 'ID' in class 'Member". This isn't an entity so I'm a little confused as to what I'm missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
那么,您的类没有指定名为
ID
的属性 - 它指定了一个字段。也许您应该尝试提供类属性而不是公共字段:Well your class doesn't specify a property called
ID
- it specifies a field. Perhaps you should try giving your class properties rather than public fields:也许尝试使用财产,这应该是虚拟的
maybe try to use property, which should be virtual