From 623f8f7cd95930cb5742d20449621cdbd15c453f Mon Sep 17 00:00:00 2001 From: Ricardo Peres Date: Sat, 18 Oct 2014 09:35:46 +0100 Subject: [PATCH 1/6] NH-3724 Added support for notification handlers (InfoMessage event in most ADO.NET drivers) Small fixes: - Base driver throws exception if a handler is passed to it - Drivers for .NET BCL classes just cast parameters to the expected types and will throw an exception if the type is wrong Logic for InfoMessage event moved to DriverBase Exception is thrown if event is not found Applied suggested fixes: removed unnecessary using directives and added . at the end of the exception message --- .../Loquacious/ConfigurationFixture.cs | 15 ++++ src/NHibernate/AdoNet/ConnectionManager.cs | 5 ++ src/NHibernate/Cfg/Configuration.cs | 7 ++ .../DbIntegrationConfigurationProperties.cs | 7 ++ .../IDbIntegrationConfigurationProperties.cs | 4 + src/NHibernate/Cfg/Settings.cs | 3 + src/NHibernate/Driver/DriverBase.cs | 16 ++++ src/NHibernate/Driver/IDriver.cs | 7 ++ src/NHibernate/Driver/IfxDriver.cs | 3 + src/NHibernate/Driver/NpgsqlDriver.cs | 7 ++ src/NHibernate/Driver/OdbcDriver.cs | 7 ++ src/NHibernate/Driver/OleDbDriver.cs | 6 ++ src/NHibernate/Driver/SQLite20Driver.cs | 80 ++++++++++--------- src/NHibernate/Driver/SqlClientDriver.cs | 6 ++ 14 files changed, 134 insertions(+), 39 deletions(-) diff --git a/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs b/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs index 327b32faddd..8ba7864c882 100644 --- a/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs +++ b/src/NHibernate.Test/CfgTest/Loquacious/ConfigurationFixture.cs @@ -1,3 +1,4 @@ +using System; using System.Data; using System.Data.SqlClient; using System.IO; @@ -11,12 +12,26 @@ using NHibernate.Hql.Ast.ANTLR; using NHibernate.Type; using NUnit.Framework; +using Environment = NHibernate.Cfg.Environment; namespace NHibernate.Test.CfgTest.Loquacious { [TestFixture] public class ConfigurationFixture { + [Test] + public void CanSetNotificationHandler() + { + //NH-3724 + EventHandler handler = (s, e) => {}; + var cfg = new Configuration().DataBaseIntegration(x => + { + x.WithNotificationHandler(handler); + }).Configure(); + + Assert.IsNotNull(cfg.NotificationHandler); + } + [Test] public void CompleteConfiguration() { diff --git a/src/NHibernate/AdoNet/ConnectionManager.cs b/src/NHibernate/AdoNet/ConnectionManager.cs index 80674df3cf5..0d27d81d4ee 100644 --- a/src/NHibernate/AdoNet/ConnectionManager.cs +++ b/src/NHibernate/AdoNet/ConnectionManager.cs @@ -240,6 +240,11 @@ public DbConnection GetConnection() if (_ownConnection) { _connection = Factory.ConnectionProvider.GetConnection(); + //NH-3724 + if (Factory.Settings.NotificationHandler != null) + { + Factory.ConnectionProvider.Driver.AddNotificationHandler(_connection, Factory.Settings.NotificationHandler); + } // Will fail if the connection is already enlisted in another transaction. // Probable case: nested transaction scope with connection auto-enlistment enabled. // That is an user error. diff --git a/src/NHibernate/Cfg/Configuration.cs b/src/NHibernate/Cfg/Configuration.cs index cf6a0623c42..f985db04087 100644 --- a/src/NHibernate/Cfg/Configuration.cs +++ b/src/NHibernate/Cfg/Configuration.cs @@ -183,6 +183,7 @@ protected void Reset() tableNameBinding = new Dictionary(); columnNameBindingPerTable = new Dictionary(); filtersSecondPasses = new Queue(); + NotificationHandler = null; } [Serializable] @@ -1405,6 +1406,10 @@ public Configuration SetDefaultNamespace(string newDefaultNamespace) return this; } + //NH-3724 + [field: NonSerialized] + public Delegate NotificationHandler { get; set; } + /// /// Sets the default interceptor for use by all sessions. /// @@ -1763,6 +1768,8 @@ private Settings BuildSettings() // NH : Set configuration for IdGenerator SQL logging PersistentIdGeneratorParmsNames.SqlStatementLogger.FormatSql = result.SqlStatementLogger.FormatSql; PersistentIdGeneratorParmsNames.SqlStatementLogger.LogToStdout = result.SqlStatementLogger.LogToStdout; + //NH-3724 + result.NotificationHandler = NotificationHandler; return result; } diff --git a/src/NHibernate/Cfg/Loquacious/DbIntegrationConfigurationProperties.cs b/src/NHibernate/Cfg/Loquacious/DbIntegrationConfigurationProperties.cs index 55131818ab4..176c98557b2 100644 --- a/src/NHibernate/Cfg/Loquacious/DbIntegrationConfigurationProperties.cs +++ b/src/NHibernate/Cfg/Loquacious/DbIntegrationConfigurationProperties.cs @@ -1,3 +1,4 @@ +using System; using System.Data; using NHibernate.AdoNet; using NHibernate.Connection; @@ -19,6 +20,12 @@ public DbIntegrationConfigurationProperties(Configuration configuration) #region Implementation of IDbIntegrationConfigurationProperties + public void WithNotificationHandler(Delegate handler) + { + //NH-3724 + configuration.NotificationHandler = handler; + } + public void Dialect() where TDialect : Dialect.Dialect { configuration.SetProperty(Environment.Dialect, typeof(TDialect).AssemblyQualifiedName); diff --git a/src/NHibernate/Cfg/Loquacious/IDbIntegrationConfigurationProperties.cs b/src/NHibernate/Cfg/Loquacious/IDbIntegrationConfigurationProperties.cs index 496ebf58433..97e53751d45 100644 --- a/src/NHibernate/Cfg/Loquacious/IDbIntegrationConfigurationProperties.cs +++ b/src/NHibernate/Cfg/Loquacious/IDbIntegrationConfigurationProperties.cs @@ -1,3 +1,4 @@ +using System; using System.Data; using NHibernate.AdoNet; using NHibernate.Connection; @@ -15,6 +16,9 @@ public interface IDbIntegrationConfigurationProperties bool LogSqlInConsole { set; } bool LogFormattedSql { set; } + //NH-3724 + void WithNotificationHandler(Delegate handler); + void ConnectionProvider() where TProvider : IConnectionProvider; void Driver() where TDriver : IDriver; IsolationLevel IsolationLevel { set; } diff --git a/src/NHibernate/Cfg/Settings.cs b/src/NHibernate/Cfg/Settings.cs index 878b9b60605..c7172b82010 100644 --- a/src/NHibernate/Cfg/Settings.cs +++ b/src/NHibernate/Cfg/Settings.cs @@ -31,6 +31,9 @@ public Settings() //private int jdbcFetchSize; #endregion + + public Delegate NotificationHandler { get; internal set; } + public SqlStatementLogger SqlStatementLogger { get; internal set; } public int MaximumFetchDepth { get; internal set; } diff --git a/src/NHibernate/Driver/DriverBase.cs b/src/NHibernate/Driver/DriverBase.cs index 1d63bc64dd8..919da515b68 100644 --- a/src/NHibernate/Driver/DriverBase.cs +++ b/src/NHibernate/Driver/DriverBase.cs @@ -21,6 +21,22 @@ public abstract class DriverBase : IDriver, ISqlParameterFormatter private int commandTimeout; private bool prepareSql; + public virtual void AddNotificationHandler(IDbConnection con, Delegate handler) + { + //NH-3724 + if (handler != null) + { + var prop = con.GetType().GetEvent("InfoMessage"); + + if (prop == null) + { + throw new NotSupportedException("Current driver does not support notifications."); + } + + prop.AddEventHandler(con, handler); + } + } + public virtual void Configure(IDictionary settings) { // Command timeout diff --git a/src/NHibernate/Driver/IDriver.cs b/src/NHibernate/Driver/IDriver.cs index 61e40b64213..d2085902a41 100644 --- a/src/NHibernate/Driver/IDriver.cs +++ b/src/NHibernate/Driver/IDriver.cs @@ -37,6 +37,13 @@ public interface IDriver /// void Configure(IDictionary settings); + //NH-3724 + /// + /// Attaches an event handler for the notification event (InfoMessage in most ADO.NET drivers). + /// + /// + void AddNotificationHandler(IDbConnection con, Delegate handler); + /// /// Creates an uninitialized DbConnection object for the specific Driver /// diff --git a/src/NHibernate/Driver/IfxDriver.cs b/src/NHibernate/Driver/IfxDriver.cs index 0d3c3bebbd2..32a18f1d7c3 100644 --- a/src/NHibernate/Driver/IfxDriver.cs +++ b/src/NHibernate/Driver/IfxDriver.cs @@ -1,3 +1,6 @@ +using System; +using System.Data; + namespace NHibernate.Driver { /// diff --git a/src/NHibernate/Driver/NpgsqlDriver.cs b/src/NHibernate/Driver/NpgsqlDriver.cs index ccfd2dc1be2..e7abf4b7ff5 100644 --- a/src/NHibernate/Driver/NpgsqlDriver.cs +++ b/src/NHibernate/Driver/NpgsqlDriver.cs @@ -1,3 +1,4 @@ +using System; using System.Data; using System.Data.Common; using NHibernate.AdoNet; @@ -41,6 +42,12 @@ public NpgsqlDriver() : base( { } + public override void AddNotificationHandler(IDbConnection con, Delegate handler) + { + //NH-3724 + con.GetType().GetEvent("Notification").AddEventHandler(con, handler); + } + public override bool UseNamedPrefixInSql => true; public override bool UseNamedPrefixInParameter => true; diff --git a/src/NHibernate/Driver/OdbcDriver.cs b/src/NHibernate/Driver/OdbcDriver.cs index 80e6358617e..ecdcbcef3da 100644 --- a/src/NHibernate/Driver/OdbcDriver.cs +++ b/src/NHibernate/Driver/OdbcDriver.cs @@ -38,6 +38,7 @@ public override void Configure(IDictionary settings) } } + #if !NETFX public OdbcDriver() : base("System.Data.Odbc", "System.Data.Odbc.OdbcConnection", "System.Data.Odbc.OdbcCommand") @@ -49,6 +50,12 @@ public override DbConnection CreateConnection() return new System.Data.Odbc.OdbcConnection(); } + public override void AddNotificationHandler(IDbConnection con, Delegate handler) + { + //NH-3724 + (con as System.Data.Odbc.OdbcConnection).InfoMessage += (System.Data.Odbc.OdbcInfoMessageEventHandler) handler; + } + public override DbCommand CreateCommand() { return new System.Data.Odbc.OdbcCommand(); diff --git a/src/NHibernate/Driver/OleDbDriver.cs b/src/NHibernate/Driver/OleDbDriver.cs index 504411995e0..7a6e2ce0c46 100644 --- a/src/NHibernate/Driver/OleDbDriver.cs +++ b/src/NHibernate/Driver/OleDbDriver.cs @@ -28,6 +28,12 @@ public override DbConnection CreateConnection() return new System.Data.OleDb.OleDbConnection(); } + public override void AddNotificationHandler(System.Data.IDbConnection con, Delegate handler) + { + //NH-3724 + (con as System.Data.OleDb.OleDbConnection).InfoMessage += (System.Data.OleDb.OleDbInfoMessageEventHandler) handler; + } + public override DbCommand CreateCommand() { return new System.Data.OleDb.OleDbCommand(); diff --git a/src/NHibernate/Driver/SQLite20Driver.cs b/src/NHibernate/Driver/SQLite20Driver.cs index 8f84a216869..343fd485533 100644 --- a/src/NHibernate/Driver/SQLite20Driver.cs +++ b/src/NHibernate/Driver/SQLite20Driver.cs @@ -3,37 +3,37 @@ namespace NHibernate.Driver { - /// - /// NHibernate driver for the System.Data.SQLite data provider for .NET. - /// - /// - /// - /// In order to use this driver you must have the System.Data.SQLite.dll assembly available - /// for NHibernate to load. This assembly includes the SQLite.dll or SQLite3.dll libraries. - /// - /// - /// You can get the System.Data.SQLite.dll assembly from + /// + /// NHibernate driver for the System.Data.SQLite data provider for .NET. + /// + /// + /// + /// In order to use this driver you must have the System.Data.SQLite.dll assembly available + /// for NHibernate to load. This assembly includes the SQLite.dll or SQLite3.dll libraries. + /// + /// + /// You can get the System.Data.SQLite.dll assembly from /// https://system.data.sqlite.org/ - /// - /// - /// Please check https://www.sqlite.org/ for more information regarding SQLite. - /// - /// - public class SQLite20Driver : ReflectionBasedDriver - { - /// - /// Initializes a new instance of . - /// - /// - /// Thrown when the SQLite.NET assembly can not be loaded. - /// - public SQLite20Driver() : base( - "System.Data.SQLite", - "System.Data.SQLite", - "System.Data.SQLite.SQLiteConnection", - "System.Data.SQLite.SQLiteCommand") - { - } + /// + /// + /// Please check https://www.sqlite.org/ for more information regarding SQLite. + /// + /// + public class SQLite20Driver : ReflectionBasedDriver + { + /// + /// Initializes a new instance of . + /// + /// + /// Thrown when the SQLite.NET assembly can not be loaded. + /// + public SQLite20Driver() : base( + "System.Data.SQLite", + "System.Data.SQLite", + "System.Data.SQLite.SQLiteConnection", + "System.Data.SQLite.SQLiteCommand") + { + } public override DbConnection CreateConnection() { @@ -57,22 +57,24 @@ private static void Connection_StateChange(object sender, StateChangeEventArgs e } } - public override IResultSetsCommand GetResultSetsCommand(Engine.ISessionImplementor session) - { - return new BasicResultSetsCommand(session); - } + - public override bool UseNamedPrefixInSql => true; + public override IResultSetsCommand GetResultSetsCommand(Engine.ISessionImplementor session) + { + return new BasicResultSetsCommand(session); + } + + public override bool UseNamedPrefixInSql => true; public override bool UseNamedPrefixInParameter => true; public override string NamedPrefix => "@"; public override bool SupportsMultipleOpenReaders => false; - - public override bool SupportsMultipleQueries => true; - - public override bool SupportsNullEnlistment => false; + + public override bool SupportsMultipleQueries => true; + + public override bool SupportsNullEnlistment => false; public override bool HasDelayedDistributedTransactionCompletion => true; } diff --git a/src/NHibernate/Driver/SqlClientDriver.cs b/src/NHibernate/Driver/SqlClientDriver.cs index 81d46097a50..c694710c01e 100644 --- a/src/NHibernate/Driver/SqlClientDriver.cs +++ b/src/NHibernate/Driver/SqlClientDriver.cs @@ -88,6 +88,12 @@ public override DbConnection CreateConnection() return new SqlConnection(); } + public override void AddNotificationHandler(IDbConnection con, Delegate handler) + { + //NH-3724 + (con as SqlConnection).InfoMessage += (SqlInfoMessageEventHandler) handler; + } + /// /// Creates an uninitialized object for /// the SqlClientDriver. From 707bb829b51ef61bb634d22859f5fe53054899b7 Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Wed, 10 Apr 2019 16:23:37 +1200 Subject: [PATCH 2/6] Use DbConnection instead of IDbConnection --- src/NHibernate/Driver/DriverBase.cs | 2 +- src/NHibernate/Driver/IDriver.cs | 3 ++- src/NHibernate/Driver/NpgsqlDriver.cs | 2 +- src/NHibernate/Driver/OdbcDriver.cs | 2 +- src/NHibernate/Driver/OleDbDriver.cs | 2 +- src/NHibernate/Driver/SqlClientDriver.cs | 3 +-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/NHibernate/Driver/DriverBase.cs b/src/NHibernate/Driver/DriverBase.cs index 919da515b68..fea21fbd627 100644 --- a/src/NHibernate/Driver/DriverBase.cs +++ b/src/NHibernate/Driver/DriverBase.cs @@ -21,7 +21,7 @@ public abstract class DriverBase : IDriver, ISqlParameterFormatter private int commandTimeout; private bool prepareSql; - public virtual void AddNotificationHandler(IDbConnection con, Delegate handler) + public virtual void AddNotificationHandler(DbConnection con, Delegate handler) { //NH-3724 if (handler != null) diff --git a/src/NHibernate/Driver/IDriver.cs b/src/NHibernate/Driver/IDriver.cs index d2085902a41..38c9f3cc978 100644 --- a/src/NHibernate/Driver/IDriver.cs +++ b/src/NHibernate/Driver/IDriver.cs @@ -41,8 +41,9 @@ public interface IDriver /// /// Attaches an event handler for the notification event (InfoMessage in most ADO.NET drivers). /// + /// /// - void AddNotificationHandler(IDbConnection con, Delegate handler); + void AddNotificationHandler(DbConnection con, Delegate handler); /// /// Creates an uninitialized DbConnection object for the specific Driver diff --git a/src/NHibernate/Driver/NpgsqlDriver.cs b/src/NHibernate/Driver/NpgsqlDriver.cs index e7abf4b7ff5..0f19e27e6ce 100644 --- a/src/NHibernate/Driver/NpgsqlDriver.cs +++ b/src/NHibernate/Driver/NpgsqlDriver.cs @@ -42,7 +42,7 @@ public NpgsqlDriver() : base( { } - public override void AddNotificationHandler(IDbConnection con, Delegate handler) + public override void AddNotificationHandler(DbConnection con, Delegate handler) { //NH-3724 con.GetType().GetEvent("Notification").AddEventHandler(con, handler); diff --git a/src/NHibernate/Driver/OdbcDriver.cs b/src/NHibernate/Driver/OdbcDriver.cs index ecdcbcef3da..68dc15cf887 100644 --- a/src/NHibernate/Driver/OdbcDriver.cs +++ b/src/NHibernate/Driver/OdbcDriver.cs @@ -50,7 +50,7 @@ public override DbConnection CreateConnection() return new System.Data.Odbc.OdbcConnection(); } - public override void AddNotificationHandler(IDbConnection con, Delegate handler) + public override void AddNotificationHandler(DbConnection con, Delegate handler) { //NH-3724 (con as System.Data.Odbc.OdbcConnection).InfoMessage += (System.Data.Odbc.OdbcInfoMessageEventHandler) handler; diff --git a/src/NHibernate/Driver/OleDbDriver.cs b/src/NHibernate/Driver/OleDbDriver.cs index 7a6e2ce0c46..e2cab75baa9 100644 --- a/src/NHibernate/Driver/OleDbDriver.cs +++ b/src/NHibernate/Driver/OleDbDriver.cs @@ -28,7 +28,7 @@ public override DbConnection CreateConnection() return new System.Data.OleDb.OleDbConnection(); } - public override void AddNotificationHandler(System.Data.IDbConnection con, Delegate handler) + public override void AddNotificationHandler(DbConnection con, Delegate handler) { //NH-3724 (con as System.Data.OleDb.OleDbConnection).InfoMessage += (System.Data.OleDb.OleDbInfoMessageEventHandler) handler; diff --git a/src/NHibernate/Driver/SqlClientDriver.cs b/src/NHibernate/Driver/SqlClientDriver.cs index c694710c01e..a65bce1ae18 100644 --- a/src/NHibernate/Driver/SqlClientDriver.cs +++ b/src/NHibernate/Driver/SqlClientDriver.cs @@ -9,7 +9,6 @@ using NHibernate.Dialect; using NHibernate.Engine; using NHibernate.SqlTypes; -using NHibernate.Type; namespace NHibernate.Driver { @@ -88,7 +87,7 @@ public override DbConnection CreateConnection() return new SqlConnection(); } - public override void AddNotificationHandler(IDbConnection con, Delegate handler) + public override void AddNotificationHandler(DbConnection con, Delegate handler) { //NH-3724 (con as SqlConnection).InfoMessage += (SqlInfoMessageEventHandler) handler; From c727758469d30302efb77a7b0c2284391a892e4d Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Mon, 15 Apr 2019 20:26:56 +1200 Subject: [PATCH 3/6] Fix field declaration --- src/NHibernate/Cfg/Configuration.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/NHibernate/Cfg/Configuration.cs b/src/NHibernate/Cfg/Configuration.cs index f985db04087..126a2a0a826 100644 --- a/src/NHibernate/Cfg/Configuration.cs +++ b/src/NHibernate/Cfg/Configuration.cs @@ -1407,8 +1407,12 @@ public Configuration SetDefaultNamespace(string newDefaultNamespace) } //NH-3724 - [field: NonSerialized] - public Delegate NotificationHandler { get; set; } + + public Delegate NotificationHandler + { + get => _notificationHandler; + set => _notificationHandler = value; + } /// /// Sets the default interceptor for use by all sessions. @@ -1935,6 +1939,9 @@ protected virtual string GetDefaultConfigurationFilePath() #endregion private XmlSchemas schemas; + + [NonSerialized] + private Delegate _notificationHandler; private XmlSchemas Schemas { From c8c55120f0c99a1b4bfdc522f5b2b99474bc7d5e Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Mon, 15 Apr 2019 20:30:14 +1200 Subject: [PATCH 4/6] fixup! NH-3724 Added support for notification handlers (InfoMessage event in most ADO.NET drivers) Fix whitespaces --- src/NHibernate/Driver/SQLite20Driver.cs | 80 ++++++++++++------------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/src/NHibernate/Driver/SQLite20Driver.cs b/src/NHibernate/Driver/SQLite20Driver.cs index 343fd485533..8f84a216869 100644 --- a/src/NHibernate/Driver/SQLite20Driver.cs +++ b/src/NHibernate/Driver/SQLite20Driver.cs @@ -3,37 +3,37 @@ namespace NHibernate.Driver { - /// - /// NHibernate driver for the System.Data.SQLite data provider for .NET. - /// - /// - /// - /// In order to use this driver you must have the System.Data.SQLite.dll assembly available - /// for NHibernate to load. This assembly includes the SQLite.dll or SQLite3.dll libraries. - /// - /// - /// You can get the System.Data.SQLite.dll assembly from + /// + /// NHibernate driver for the System.Data.SQLite data provider for .NET. + /// + /// + /// + /// In order to use this driver you must have the System.Data.SQLite.dll assembly available + /// for NHibernate to load. This assembly includes the SQLite.dll or SQLite3.dll libraries. + /// + /// + /// You can get the System.Data.SQLite.dll assembly from /// https://system.data.sqlite.org/ - /// - /// - /// Please check https://www.sqlite.org/ for more information regarding SQLite. - /// - /// - public class SQLite20Driver : ReflectionBasedDriver - { - /// - /// Initializes a new instance of . - /// - /// - /// Thrown when the SQLite.NET assembly can not be loaded. - /// - public SQLite20Driver() : base( - "System.Data.SQLite", - "System.Data.SQLite", - "System.Data.SQLite.SQLiteConnection", - "System.Data.SQLite.SQLiteCommand") - { - } + /// + /// + /// Please check https://www.sqlite.org/ for more information regarding SQLite. + /// + /// + public class SQLite20Driver : ReflectionBasedDriver + { + /// + /// Initializes a new instance of . + /// + /// + /// Thrown when the SQLite.NET assembly can not be loaded. + /// + public SQLite20Driver() : base( + "System.Data.SQLite", + "System.Data.SQLite", + "System.Data.SQLite.SQLiteConnection", + "System.Data.SQLite.SQLiteCommand") + { + } public override DbConnection CreateConnection() { @@ -57,24 +57,22 @@ private static void Connection_StateChange(object sender, StateChangeEventArgs e } } - - - public override IResultSetsCommand GetResultSetsCommand(Engine.ISessionImplementor session) - { - return new BasicResultSetsCommand(session); - } + public override IResultSetsCommand GetResultSetsCommand(Engine.ISessionImplementor session) + { + return new BasicResultSetsCommand(session); + } - public override bool UseNamedPrefixInSql => true; + public override bool UseNamedPrefixInSql => true; public override bool UseNamedPrefixInParameter => true; public override string NamedPrefix => "@"; public override bool SupportsMultipleOpenReaders => false; - - public override bool SupportsMultipleQueries => true; - - public override bool SupportsNullEnlistment => false; + + public override bool SupportsMultipleQueries => true; + + public override bool SupportsNullEnlistment => false; public override bool HasDelayedDistributedTransactionCompletion => true; } From 0e59c07bb3f5c10b861ef64dcf20d63d1feb5e4d Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Mon, 15 Apr 2019 21:36:42 +1200 Subject: [PATCH 5/6] fixup! NH-3724 Added support for notification handlers (InfoMessage event in most ADO.NET drivers) Fix whitespaces --- src/NHibernate/Async/AdoNet/ConnectionManager.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NHibernate/Async/AdoNet/ConnectionManager.cs b/src/NHibernate/Async/AdoNet/ConnectionManager.cs index a7a942d8735..ce8db4cc505 100644 --- a/src/NHibernate/Async/AdoNet/ConnectionManager.cs +++ b/src/NHibernate/Async/AdoNet/ConnectionManager.cs @@ -62,6 +62,11 @@ async Task InternalGetConnectionAsync() if (_ownConnection) { _connection = await (Factory.ConnectionProvider.GetConnectionAsync(cancellationToken)).ConfigureAwait(false); + //NH-3724 + if (Factory.Settings.NotificationHandler != null) + { + Factory.ConnectionProvider.Driver.AddNotificationHandler(_connection, Factory.Settings.NotificationHandler); + } // Will fail if the connection is already enlisted in another transaction. // Probable case: nested transaction scope with connection auto-enlistment enabled. // That is an user error. From db3ffad85990ddd6216e096c03854116ae64d45d Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Mon, 15 Apr 2019 21:36:58 +1200 Subject: [PATCH 6/6] Fix build --- src/NHibernate.Test/NHSpecificTest/GH1547/Fixture.cs | 5 +++++ src/NHibernate.Test/TypesTest/AbstractDateTimeTypeFixture.cs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/NHibernate.Test/NHSpecificTest/GH1547/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/GH1547/Fixture.cs index 22267fb030c..bf2431d5f3e 100644 --- a/src/NHibernate.Test/NHSpecificTest/GH1547/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/GH1547/Fixture.cs @@ -179,6 +179,11 @@ void IDriver.Configure(IDictionary settings) _driverImplementation.Configure(settings); } + public void AddNotificationHandler(DbConnection con, Delegate handler) + { + _driverImplementation.AddNotificationHandler(con, handler); + } + DbConnection IDriver.CreateConnection() { return _driverImplementation.CreateConnection(); diff --git a/src/NHibernate.Test/TypesTest/AbstractDateTimeTypeFixture.cs b/src/NHibernate.Test/TypesTest/AbstractDateTimeTypeFixture.cs index 67b36a0d2cc..61559329d39 100644 --- a/src/NHibernate.Test/TypesTest/AbstractDateTimeTypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/AbstractDateTimeTypeFixture.cs @@ -630,6 +630,11 @@ void IDriver.Configure(IDictionary settings) _driverImplementation.Configure(settings); } + public void AddNotificationHandler(DbConnection con, Delegate handler) + { + _driverImplementation.AddNotificationHandler(con, handler); + } + DbConnection IDriver.CreateConnection() { return _driverImplementation.CreateConnection();