Help returning DataReader in Async "world". #1250
Replies: 4 comments 3 replies
-
What I suspect is... |
Beta Was this translation helpful? Give feedback.
-
The problem is this line: await using var connection = (MySqlConnection) DbHelper.CreateDbConnection(ProviderName, ConnectionString); When the One solution is to use With this behaviour, the returned reader will keep the connection open until you dispose it, then it will close the connection. There are some examples of doing this, as well as some pros and cons of the whole approach, at https://stackoverflow.com/questions/5689263/what-is-the-use-advantage-of-using-commandbehavior-closeconnection-in-executerea. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Ahm... that make me struggle for some hours. The variable What I suspect is that there are two execution paths overlapped and one of them really raises exception. I made a last test changing code, instead of throw I return null. What I found is:
Sorry, cannot help more. I will document in my code this scenario for future reference. |
Beta Was this translation helpful? Give feedback.
-
Hi,
doing some test with this library because the Oracle one is too bugged when connecting to MariaDb and this lib is very promising.
I'm very attracted by the Async features, I would like to migrate all currently developing software.
Need help... line
return await command.ExecuteReaderAsync();
throws an exception.Is the way I use it not correct.
I read again and again this snippet and nothing seems weird.
If, instead of returning the DataReader, I loop through it works.
Some suggestion?
Thanks
Follow snippet
Beta Was this translation helpful? Give feedback.
All reactions