NHibernate: how to reconfigure mappings at runtime?

Let me first deal with this: I know that SessionFactory is immutable - I am trying to change the configuration at runtime and restore ISessionFactory.

In particular, I have a mapped client that will have some fields added to its dynamic node component at runtime. I would like to do something like this

var newSessionFactory = previousConfiguration
  .RemoveClassMapping(typeof(Customer))
  .AddXmlString(newMappingForCustomer)
  .BuildSessionFactory();

However, I don't see an obvious way to remove the mapping, is there anything I can do without regenerating the whole configuration?

+5
source share
1 answer

It's impossible. You will need to recover Configuration.

, .

, :-), :

  • "" Configuration ( Customer)
  • MemoryStream
  • "" Customer ,
  • SessionFactory
  • , Customer
  • Configuration
  • Customer SessionFactory
+1

All Articles