我有具有关键字和关键字属性的页面实体。
Keyword
属性存储一个字符串,如string Keyword = "my awesome page, page";
关键字会将这些信息存储在数据库中。
另一方面,关键字检索此关键字内容并用逗号分隔。
所以我在我的模型里面
public Page : Entity<int>
{
public virtual string Keyword {get; set;}
public virtual IList<string> Keywords
{
get { return Keyword.Split(','); }
set { Keyword = string.Join(",", value); }
}
public Page() { Keywords = new List<string>(); }
}
所以我尝试通过代码将这个实体映射到顺从映射
public class PageMap : ClassMapping<Page>
{
public PageMap()
{
Property(x => x.Keyword);
Property(x => x.Keywords, m =>
{
m.Access(Accessor.Field);
});
}
}
但我得到了像
NHibernate.MappingException:无法编译映射文档:mapping_by_code ----> NHibernate.MappingException:尝试通过反射设置属性类型时出现问题 NHibernate.PropertyNotFoundException:在“Model.Page”类中找不到属性或字段“关键字”
即使我明白找不到财产的消息,我也不明白为什么?以及如何克服这一点。
谢谢