到目前为止,我使用此代码配置会话工厂:
Configuration configuration = new Configuration();
configuration.Configure();
SessionFactory = configuration.BuildSessionFactory();
现在我添加了一些fluentNhibernate映射类,并使用此代码配置:
Configuration configuration = new Configuration();
configuration.Configure();
SessionFactory = configuration.BuildSessionFactory();
SessionFactory = Fluently.Configure(configuration).Mappings(m =>
{
m.FluentMappings.AddFromAssemblyOf<AttachmentLocaionMap>();
m.FluentMappings.AddFromAssemblyOf<AttachmentTypeMap>();
m.FluentMappings.AddFromAssemblyOf<AttachmentMap>();
}).BuildSessionFactory();
但我猜它覆盖了旧的xml映射? 现在我想添加然后添加到已存在的 exmbeded资源基于xml的映射
我该怎么做?
我看到了blog,但我不想添加
configuration.AddXmlFile(“Mappings / Insurance.hbm.xml”); 要么 configuration.AddAssembly(...);
对于每个现有的xml(到目前为止,我不为每个ebmbeded资源xml做这个)
答案 0 :(得分:2)
SessionFactory = Fluently.Configure(configuration).Mappings(m =>
{
m.FluentMappings.AddFromAssemblyOf<AttachmentLocaionMap>();
m.FluentMappings.AddFromAssemblyOf<AttachmentTypeMap>();
m.FluentMappings.AddFromAssemblyOf<AttachmentMap>();
m.HbmMappings.AddFromAssemblyOf<SomeTypeFromYourAssemblyWithHbmMappings>()
}).BuildSessionFactory();