.NET CORE 6 - Injecting IDbConnection... is it good practice?
I have an api to build and using dapper - IDbConnection. Atm i have an instance of IDbConnection for every db call and i dispose it immediately:
Since i only have one sql database to query, is it good practice to inject the dbConnection on startup?
Will this cause any performance issue since the connection will stay open all the time (if i'm correct)?
3 Replies
i do not see a problem with this
noice, thanks
gave it a try
all seem to be good
I would probably inject a connection factory, or connection pool
But i often deal with multiple databases