adding an nHibernate mapping at run time?

后端 未结 2 699
死守一世寂寞
死守一世寂寞 2020-12-18 10:13

Background:

I\'m getting a mapping failure when trying to use nHibernate. The application consists of several assemblies. One of the assemblies is a

相关标签:
2条回答
  • 2020-12-18 10:37

    Re your comment - no you cannot add mappings once you constructed your session factory. You can however re-create the session factory. Keep in mind though that it can be expensive operation (a second or so).

    0 讨论(0)
  • 2020-12-18 10:42

    You can add mappings at runtime at the moment your session factory is being constructed:

    ISessionFactory sf = new Configuration()
        .AddFile("Item.hbm.xml")
        .AddFile("Bid.hbm.xml")
        .BuildSessionFactory();
    

    or with assemblies:

    ISessionFactory sf = new Configuration()
        .AddAssembly("NHibernate.Auction")
        .BuildSessionFactory();
    
    0 讨论(0)
提交回复
热议问题