My NHibernate configuration is set to show sql for all interactions. Because of this, some of my larger integration tests are performing poorly (particularly when generating the test report).
Is there a way to turn off ShowSql at runtime - and then switch it back on programmatically.
You can use SetProperties() on you configuration object at runtime, and then create a SessionFactory from that configuration. SetProperties takes a Dictionary as a parameter. The new SessionFactory will then use the new configuration settings.
IDictionary<string, string> props = new Dictionary<string, string>();
props["show_sql"] = "true";
Configuration config = new NHibernate.Cfg.Configuration();
config.SetProperties(props);
config.Configure();
config.AddAssembly(typeof(User).Assembly);
ISessionFactory factory = config.BuildSessionFactory();
For more info, check out this section of the docs: ISessionFactory Configuration
Hope it helps.
/Erik
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With