Closed rokern002 closed 5 years ago
If your DI container opens the connection, then Insight will not close it. There is no close-only mode.
I really have to open connection on initialization (addscoped)? what if i have a service call before database access... the service result is invalid, but i already opened the connection even i no need one. kinda inefficient
Insight works by using an IDbConnection, if that connection is passed opened, it will remain open, if the connection is closed, insight will open/close it for you as explained on the wiki. Do you have a specific scenario where it doesnt work as intended? Feel free to post a sample.
When we performance-tested the various modes, we found:
Manual open/close is generally used when you have multiple database calls that you want to bind in a transaction.
The general MSFT advice is to rely on the connection pool to do its job, but if you're measuring actual performance problems you can easily write your own wrapper for the DbConnection and do your own open/close semantics.
Closing due to inactivity.
Hi, is it possible to configure insight database (6.2.8) have auto open connection but not close it? I would like to use scoped injection in asp.net core 2.1 project on IDbConnection and reuse the connection for the current request in my rest application (scope).
the goal is, let DI container to decide if element should be disposed or not.