Igo*_*rup 13 c# nhibernate connection-timeout
在NHibernate连接失败(连接超时)之前,有没有办法全局设置等待连接到给定数据库的时间?在ADO.NET中,您可以为这样的单个连接执行此操作:
new SqlConnection().ConnectionTimeout = 10;
Run Code Online (Sandbox Code Playgroud)
我发现,你会如何设置时间等待一个结果集,命令执行失败之前这里(命令超时).但是,显然,这不是我需要的
amc*_*ott 18
您可以使用command_timeoutNHibernate配置代码中的设置.有关完整详细信息,请参阅文档的第3.4节.
这个的XML配置如下......
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="dialect">NHibernate.Dialect.MsSql2012Dialect</property>
<property name="connection.connection_string">
Server=(local);initial catalog=theDb;Integrated Security=SSPI
</property>
<property name="command_timeout">100</property>
</session-factory>
</hibernate-configuration>
<!-- other app specific config follows -->
Run Code Online (Sandbox Code Playgroud)
我正在使用Fluent NHibernate,所以我的配置代码如下......
FluentConfiguration configuration = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2012.ConnectionString(ConnectionString))
.ExposeConfiguration(cfg => cfg
.SetProperty("command_timeout", "100")
.Mappings(m =>
{
var cfg = CreateAutomappings();
m.AutoMappings.Add(cfg);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14041 次 |
| 最近记录: |