在 Fluent Initialise 方法中,您必须像这样传递几个参数,
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();
}
注意每个属性后面的“180”,这会将命令超时设置为 3 分钟
编辑:刚刚注意到您想通过基本记录在记录上执行此操作,哎呀!