到目前为止,我用这个code配置会话工厂:
配置配置=新配置();
configuration.Configure();
SessionFactory的= configuration.BuildSessionFactory();
现在我加了一些fluentNhibernate映射类,并用此code配置:
配置配置=新配置();
configuration.Configure();
SessionFactory的= configuration.BuildSessionFactory();
SessionFactory的= Fluently.Configure(配置).Mappings(M =>
{
m.FluentMappings.AddFromAssemblyOf&其中; AttachmentLocaionMap>();
m.FluentMappings.AddFromAssemblyOf&其中; AttachmentTypeMap>();
m.FluentMappings.AddFromAssemblyOf&其中; AttachmentMap>();
})BuildSessionFactory()。
不过,我想这overrided老的XML映射? 现在我想为添加,然后到现有 exmbeded资源XML为基础的映射
我如何做到这一点?
我看到这个博客,但我不希望添加
configuration.AddXmlFile(映射/ Insurance.hbm.xml); 要么 configuration.AddAssembly(...);
对于每个现有的XML(如到现在为止我dodn't做到这一点对每个ebmbeded资源XML)
解决方案 的SessionFactory = Fluently.Configure(配置).Mappings(M =>
{
m.FluentMappings.AddFromAssemblyOf&其中; AttachmentLocaionMap>();
m.FluentMappings.AddFromAssemblyOf&其中; AttachmentTypeMap>();
m.FluentMappings.AddFromAssemblyOf&其中; AttachmentMap>();
m.HbmMappings.AddFromAssemblyOf< SomeTypeFromYourAssemblyWithHbmMappings>()
})BuildSessionFactory()。
So far I used this code to configure a session factory:
Configuration configuration = new Configuration();
configuration.Configure();
SessionFactory = configuration.BuildSessionFactory();
Now I added some fluentNhibernate mapping classes, and used this code to configure:
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();
But I guess it overrided the old xml mapping? Now I want to add then to the already existing exmbeded resources xml-based mapping
How do I do this?
i saw this blog, but i don't want to add
configuration.AddXmlFile( "Mappings/Insurance.hbm.xml" ); or configuration.AddAssembly(...);
for each existing xml (as up till now I dodn't do it for each ebmbeded resource xml)
解决方案 SessionFactory = Fluently.Configure(configuration).Mappings(m =>
{
m.FluentMappings.AddFromAssemblyOf<AttachmentLocaionMap>();
m.FluentMappings.AddFromAssemblyOf<AttachmentTypeMap>();
m.FluentMappings.AddFromAssemblyOf<AttachmentMap>();
m.HbmMappings.AddFromAssemblyOf<SomeTypeFromYourAssemblyWithHbmMappings>()
}).BuildSessionFactory();