【发布时间】:2014-04-25 21:13:45
【问题描述】:
我在单独的类中创建了一个 HibernateMapping。映射和类在一个程序集中。我用来测试的 NUnit 测试在另一个程序集中。 我想我在这篇文章中做到了this
class testMapping : ClassMapping<test>{
//myMappings
}
现在我创建了一个映射器并将其添加到我的配置中:
var cfg=new Configuration();
cfg.Configure();
var mapper = new ModelMapper();
mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());
cfg.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntries());
var session = cfg.BuildSessionFactory();
但找不到我的映射。
我是否将mapper.AddMappings() 替换为:
mapper.AddMappings(New List<SystemType> {typeof(testMapping)});
它会起作用的。
我使用 GetExecutingAssembly 是否错误?
我不想单独添加我的所有映射。
【问题讨论】:
标签: c# nhibernate nhibernate-mapping .net-assembly