Skip to content

Commit 109f085

Browse files
committed
Make SqlClientBatchingBatcher respect CommandTimeout seting in configuration
Fixes #1158
1 parent f633248 commit 109f085

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
using System.Data.Common;
44
using System.Text;
55
using NHibernate.AdoNet.Util;
6+
using NHibernate.Driver;
67
using NHibernate.Exceptions;
7-
using NHibernate.Util;
88

99
namespace NHibernate.AdoNet
1010
{
@@ -20,7 +20,7 @@ public SqlClientBatchingBatcher(ConnectionManager connectionManager, IIntercepto
2020
: base(connectionManager, interceptor)
2121
{
2222
_batchSize = Factory.Settings.AdoBatchSize;
23-
_defaultTimeout = PropertiesHelper.GetInt32(Cfg.Environment.CommandTimeout, Cfg.Environment.Properties, -1);
23+
_defaultTimeout = Driver.GetCommandTimeout();
2424

2525
_currentBatch = CreateConfiguredBatch();
2626
//we always create this, because we need to deal with a scenario in which

src/NHibernate/Async/AdoNet/SqlClientBatchingBatcher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
using System.Data.Common;
1414
using System.Text;
1515
using NHibernate.AdoNet.Util;
16+
using NHibernate.Driver;
1617
using NHibernate.Exceptions;
17-
using NHibernate.Util;
1818

1919
namespace NHibernate.AdoNet
2020
{

src/NHibernate/Driver/DriverBase.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,5 +345,11 @@ public DbParameter GenerateOutputParameter(DbCommand command)
345345

346346
/// <inheritdoc />
347347
public virtual DateTime MinDate => DateTime.MinValue;
348+
349+
//6.0 TODO: Add property definition to IDialect
350+
/// <summary>
351+
/// Get the timeout in seconds for ADO.NET queries.
352+
/// </summary>
353+
public virtual int CommandTimeout => commandTimeout;
348354
}
349355
}

src/NHibernate/Driver/DriverExtensions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Data.Common;
33
using NHibernate.AdoNet;
44
using NHibernate.SqlTypes;
5+
using NHibernate.Util;
56

67
namespace NHibernate.Driver
78
{
@@ -13,6 +14,15 @@ internal static void AdjustParameterForValue(this IDriver driver, DbParameter pa
1314
adjustingDriver?.AdjustParameterForValue(parameter, sqlType, value);
1415
}
1516

17+
//6.0 TODO: inline
18+
internal static int GetCommandTimeout(this IDriver driver)
19+
{
20+
if (driver is DriverBase driverBase)
21+
return driverBase.CommandTimeout;
22+
23+
return PropertiesHelper.GetInt32(Cfg.Environment.CommandTimeout, Cfg.Environment.Properties, -1);
24+
}
25+
1626
// 6.0 TODO: merge into IDriver
1727
/// <summary>
1828
/// Begin an ADO <see cref="DbTransaction" />.

0 commit comments

Comments
 (0)