State of Db.Connection #1347
-
Should we be using something like Or do we ever Close the connection? How do we Open it on every use but not close, if we issue the OpenAsync everytime there will be an error that its already open? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Just connect with a try.. catch block. Yes the connection closed (pooled) inside a using block. |
Beta Was this translation helpful? Give feedback.
-
No.
using (var connection = new MySqlConnection(myConnectionString))
{
await connection.OpenAsync();
// ...
// it will be closed at the end of this block
} |
Beta Was this translation helpful? Give feedback.
I went with this..