Try our conversational search powered by Generative AI!

Question regarding IDatabaseHandler & IDatabaseExecutor


I'm following a tutorial related to storing custom data in Episerver, and one of the libraries referenced is IDatabaseHandler, which is obsolete. The documentation states to use IDatabaseHandler, but the property I'm looking to access from IDatabaseHandler is the ConnectionsStrings, which is not valid on that interface. Can someone provide me the best route to obtain the ConnectionStrings.ConnectionString lookup interface for the latest library, so I can access the database for creating a custom table?

Thank you,

Jul 16, 2019 23:06

I ended up just getting the string directly from ConfigManager.

Jul 17, 2019 18:26

Yeah, using ConfigurationManager.ConnectionStrings is indeed the easiest way to get connection strings.

But if you want an injected abstraction, you can have a look at the IDatabaseConnectionResolver interface. And if you run a Commerce solution, the IConnectionStringHandler interface is even simpler to use.

Jul 18, 2019 7:35

Late to the party, but just to add - don't rely on fact that connection will always be named "EPiServerDB". it can be anything.

To get the name of the connection string used in solution - you can use "EPiServerDataStoreSection.Instance.DataSettings.ConnectionStringName" property value.

Jul 21, 2019 19:28
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.