using fluent-nhibernate and traditionally hbm.xml together

让人想犯罪 __ 提交于 2019-12-20 04:59:09

问题


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)


回答1:


    SessionFactory = Fluently.Configure(configuration).Mappings(m =>
{
    m.FluentMappings.AddFromAssemblyOf<AttachmentLocaionMap>();
    m.FluentMappings.AddFromAssemblyOf<AttachmentTypeMap>();
    m.FluentMappings.AddFromAssemblyOf<AttachmentMap>();
    m.HbmMappings.AddFromAssemblyOf<SomeTypeFromYourAssemblyWithHbmMappings>()
 }).BuildSessionFactory();


来源:https://stackoverflow.com/questions/8277773/using-fluent-nhibernate-and-traditionally-hbm-xml-together

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!