4

How can i set an Session.DBCommand.CommandTimeOut NHibernate default value with Castle ActiveRecord?

this config line don't work.

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

edit: i need some code that changes the CommandTimeOut value when the command is created, what about reflection to set dynamically the value? or PostSharp? someone knows how to?

Dustin Davis
  • 14,482
  • 13
  • 63
  • 119
manuellt
  • 669
  • 2
  • 7
  • 19

1 Answers1

0

Inside the Fluent Initialise Method you must pass a couple of parameters as so,

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();
    }

Notice the "180" after each property, this will set the command timeout to be 3 minutes

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

Tom Baker
  • 61
  • 1
  • 9