nhibernate 不从程序集中获取映射
我正在使用 fnh 和 castle nhib 设施。
我在这里遵循了迈克·哈德洛的建议: http://mikehadlow .blogspot.com/2009/01/integrating- Fluent-nhibernate-and.html
这是我的 FluentNHibernateConfigurationBuilder:
public Configuration GetConfiguration(IConfiguration facilityConfiguration)
{
var defaultConfigurationBuilder = new DefaultConfigurationBuilder();
var configuration = defaultConfigurationBuilder.GetConfiguration(facilityConfiguration);
configuration.AddMappingsFromAssembly(typeof(User).Assembly);
return configuration;
}
我知道该工具正在拾取它,因为我可以突破该方法并逐步执行。
但是,完成后,不会创建任何映射,并且当我尝试保存实体时出现以下错误:
没有持久化:IsItGd.Model.Entities.User
这是我的用户类:
//simple model of web user
public class User
{
public virtual int Id { get; set; }
public virtual string FullName { get; set; }
}
这是映射:
public class UserMap : ClassMap<User>
{
public UserMap() {
Id(x=>x.Id);
Map(x=>x.FullName);
}
}
i实在看不出问题所在。 奇怪的是 - 如果我使用自动映射,它会拾取所有内容 - 但我不想使用自动映射,因为在这种情况下我无法做某些事情。
有什么线索吗?
w://
I'm using fnh and castle nhib facility.
I followed the advice from mike hadlow here: http://mikehadlow.blogspot.com/2009/01/integrating-fluent-nhibernate-and.html
here is my FluentNHibernateConfigurationBuilder:
public Configuration GetConfiguration(IConfiguration facilityConfiguration)
{
var defaultConfigurationBuilder = new DefaultConfigurationBuilder();
var configuration = defaultConfigurationBuilder.GetConfiguration(facilityConfiguration);
configuration.AddMappingsFromAssembly(typeof(User).Assembly);
return configuration;
}
i know the facility is picking it up as i can break inside that method and it steps through.
however, when it's done, non of the mappings are created and i get the following error when i try to save an entity:
No persister for: IsItGd.Model.Entities.User
here is my user class:
//simple model of web user
public class User
{
public virtual int Id { get; set; }
public virtual string FullName { get; set; }
}
and here is the mapping:
public class UserMap : ClassMap<User>
{
public UserMap() {
Id(x=>x.Id);
Map(x=>x.FullName);
}
}
i really can't see what the problem is. the strange thing is - is that if i use automapping it picks everything up - but i don't want to use automapping as i can't do certain things in that scenario.
any clues?
w://
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此问题已修复 - 这是 fnh 中的一个错误:(
this has been fixed - it was a bug in fnh :(
您的映射文件是否与域类位于同一程序集中? 否则,在指定要查找的程序集时,您可能希望使用 UserMap 而不是 User:
Are your mapping files located in the same assembly as you domain classes? Otherwise you might want to use UserMap instead of User when specifying the assembly to look in: