-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NHibernate async operations are not supported #35
Comments
There’s still some people that actively use the library so feel free to submit a pull request with the fix.
…--
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.
|
Hey @gmcelhanon could you do a PR for this change? I'd highly appreciate it. |
@Will-Bill Finally got around to this! PR opened: #38 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When trying to use this library with code utilizing the new asynchronous support added to NHibernate 5, you will encounter the following exception:
The source of the problem is that (previously) some of the NHibernate methods in the
SqlClientBatchingBatcher
class have been replaced (copy/paste/modify) in theReliableSqlClientBatchingBatcher
class with versions that handle the cast of theReliableSqlCommand
(which derives fromDbCommand
and notSqlCommand
) 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.
The text was updated successfully, but these errors were encountered: