Elad Benda
Elad Benda

Reputation: 36674

using fluent-nhibernate and traditionally hbm.xml together

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)

Upvotes: 1

Views: 3123

Answers (1)

Dave Rael
Dave Rael

Reputation: 1759

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

Upvotes: 2

Related Questions