How to set the default value of NHibernate CommandTimeOut

How to set default Session.DBCommand.CommandTimeOut NHibernate to default with Castle ActiveRecord?

this configuration line does not work.

<activerecord > <config> <add key="command_timeout" value="60"/> </config> </activerecord> 

edit: I need code that changes the value of CommandTimeOut when creating a command, but what about reflection, to set the value dynamically? or PostSharp? Does anyone know how?

+4
source share
1 answer

Inside the Fluent Initialise Method, you must pass a couple of parameters like this

 public static void Initialise(string connStr) { _Factory = Fluently.Configure().Database( MsSqlConfiguration.MsSql2005 .ConnectionString(connStr)) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<SessionHandler>()) .ExposeConfiguration(cfg => { // This will set the command_timeout property on factory-level cfg.SetProperty(NHibernate.Cfg.Environment.CommandTimeout, "180"); // This will set the command_timeout property on system-level NHibernate.Cfg.Environment.Properties.Add(NHibernate.Cfg.Environment.CommandTimeout, "180"); }) .BuildSessionFactory(); } 

Pay attention to "180" after each property, this will set the command timeout to 3 minutes

edit: just noticed that you want to do this on a basic, whoops record!

0
source

Source: https://habr.com/ru/post/1381701/


All Articles