流畅的 NHibernate 映射
我的类 filter.cs 具有以下属性:
public virtual int Id { get; set; }
public virtual Attribute Attribute { get; set; }
public virtual Int16 Type { get; set; }
public virtual string FilterValue { get; set; }
public virtual ReportConfiguration ReportConfiguration { get; set; }
Attribute 和 ReportConfiguration 是外键。
我做了这个映射:
Id(a => a.Id).UnsavedValue(0).GeneratedBy.Identity();
Map(a => a.Type);
Map(a => a.FilterValue);
References(x => x.ReportConfiguration).Column("IdReportConfiguration").Not.LazyLoad();
References(x => x.Attribute).Column("IdAttribute").Not.LazyLoad();
此外,我有一个 Repository 类,例如其方法:
public int Create(Filter F)
{
int FilterId = 0;
Transactional(session =>
{
FilterId = (int)session.Save(F);
});
return FilterId;
}
当我进行 Create(Filter F)
的单元测试时,它产生了一个异常:
No persister for: .. ..Filter.cs
我认为映射不正确。
有什么想法吗?
谢谢并致以诚挚的问候。
I have the class filter.cs with this attributes:
public virtual int Id { get; set; }
public virtual Attribute Attribute { get; set; }
public virtual Int16 Type { get; set; }
public virtual string FilterValue { get; set; }
public virtual ReportConfiguration ReportConfiguration { get; set; }
Attribute and ReportConfiguration are a Foreign Key.
I made this mapping:
Id(a => a.Id).UnsavedValue(0).GeneratedBy.Identity();
Map(a => a.Type);
Map(a => a.FilterValue);
References(x => x.ReportConfiguration).Column("IdReportConfiguration").Not.LazyLoad();
References(x => x.Attribute).Column("IdAttribute").Not.LazyLoad();
In addition, I have a Repository class for example with the method:
public int Create(Filter F)
{
int FilterId = 0;
Transactional(session =>
{
FilterId = (int)session.Save(F);
});
return FilterId;
}
And when I did the Unit Test of Create(Filter F)
it produced an exception:
No persister for: ....Filter.cs
I think the mapping is not correct.
Any idea?
Thanks and best regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这里试试:
流畅Nhibernate 没有持久化:
从上面的帖子:
这是你的情况吗?
这是一个类似的问题:
Fluent Nhibernate No Persistor for Class Name
Try here:
Fluent Nhibernate No persister for:
From the above post:
Is this your situation?
This is a similar question:
Fluent Nhibernate No Persistor for Class Name