You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to use this library with code utilizing the new asynchronous support added to NHibernate 5, you will encounter the following exception:
System.InvalidCastException: Unable to cast object of type 'NHibernate.SqlAzure.ReliableSqlCommand' to type 'System.Data.SqlClient.SqlCommand'.
at NHibernate.AdoNet.SqlClientBatchingBatcher.AddToBatchAsync(IExpectation expectation, CancellationToken cancellationToken)
The source of the problem is that (previously) some of the NHibernate methods in the SqlClientBatchingBatcher class have been replaced (copy/paste/modify) in the ReliableSqlClientBatchingBatcher class with versions that handle the cast of the ReliableSqlCommand (which derives from DbCommand and not SqlCommand) appropriately.
With the new asynchronous methods in NHibernate here, the code that executes is once again the NHibernate version, and it tries to cast the command to a SqlCommand and the exception occurs.
I have fixed the problem locally in our code base by copying the new asynchronous methods in NHibernate down into the ReliableSqlClientBatchingBatcher class and followed the same pattern that was originally used on the synchronous implementation in this library.
I wanted to at least report the problem as it may help others who might encounter this issue. Given the low level of nuget downloads and maintenance activity on the project, I'm not sure a PR would be particularly useful here.
On 3 Apr 2021, at 11:33 am, Geoff McElhanon ***@***.***> wrote:
When trying to use this library with code utilizing the new asynchronous support added to NHibernate 5, you will encounter the following exception:
System.InvalidCastException: Unable to cast object of type 'NHibernate.SqlAzure.ReliableSqlCommand' to type 'System.Data.SqlClient.SqlCommand'.
at NHibernate.AdoNet.SqlClientBatchingBatcher.AddToBatchAsync(IExpectation expectation, CancellationToken cancellationToken)
The source of the problem is that (previously) some of the NHibernate methods in the SqlClientBatchingBatcher class have been replaced (copy/paste/modify) in the ReliableSqlClientBatchingBatcher class with versions that handle the cast of the ReliableSqlCommand (which derives from DbCommand and not SqlCommand) appropriately.
With the new asynchronous methods in NHibernate here, the code that executes is once again the NHibernate version, and it tries to cast the command to a SqlCommand and the exception occurs.
I have fixed the problem locally in our code base by copying the new asynchronous methods in NHibernate down into the ReliableSqlClientBatchingBatcher class and followed the same pattern that was originally used on the synchronous implementation in this library.
I wanted to at least report the problem as it may help others who might encounter this issue. Given the low level of nuget downloads and maintenance activity on the project, I'm not sure a PR would be particularly useful here.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Activity
robdmoore commentedon Apr 3, 2021
Will-Bill commentedon May 21, 2021
Hey @gmcelhanon could you do a PR for this change? I'd highly appreciate it.
gmcelhanon commentedon Jul 11, 2021
@Will-Bill Finally got around to this! PR opened: #38