-
Notifications
You must be signed in to change notification settings - Fork 50
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
Async support for other operations #7
Conversation
…produces the same result as sync execution.
…SERT and UPDATE) and their extension methods.
Having an exception in the Insert person async and Update person async tests I created. Stack trace below. Not exactly sure what would be causing a "System.InvalidCastException : Unable to cast object of type 'Dapper.GraphQL.Test.DbConnectionWrapper' to type 'System.Data.Common.DbConnection'.". I mean that would make sense since DbConnectionWrapper is only implementing IDbConnection and isn't a DbConnection per se. Is that Dapper accepting the interface in method sigs but casting to the concrete implementation incorrectly? ===== Result StackTrace: |
Try calling Still, that error message is very misleading. We should see if we can get a very direct exception message back to the consumer so they aren't scratching their heads at this one. |
Weird, as you said doing Is this unique to the Async variants of Dapper methods? We could add a check on connection.State in the It bothers me though that this is Dapper potentially handling Sync vs Async executions differently. What do you think? |
… now while we discuss options.
Ah. DbConnection also has an OpenAsync() method, but the strange thing is Dapper has code to open the connection for you (which doesn't appear to be called): I'm not sure why that line isn't being executed - I've seen a lot of examples where |
Hey @dougrday , looks like the issue is that for the async versions of the methods Dapper try to cast the connection to a concrete DbConnection to then open it, whereas for the standard versions they don't. It's surfacing for us because they only try open it if it's closed. I'll download their repo tomorrow and see why they need to be casting. It could be a bug in Dapper if the cast is unnecessary or can't be made to a more generic IDbConnection. Thanks for looking into it more. Two heads are better than one! |
Yea looks like IDbConnection doesn't have an OpenAsync member... |
Just found a relevant issue in Dapper here: DapperLib/Dapper#757 |
Looks good, thanks again :) |
Adds on to work in issue #1 and previous PR #5.