Hoang Tran
Hoang Tran

Reputation: 956

How to get connection string in AppService?

Is it possible to get the connection string from an AppService? I want to use Dapper directly as below:

using (IDbConnection db = new SqlConnection(_connString))
{
   //My code here
}

Can I get _connString from AppService?

Upvotes: 0

Views: 947

Answers (1)

Alper Ebicoglu
Alper Ebicoglu

Reputation: 9634

there's a Dapper integration of ABP.

install Dapper from Nuget https://www.nuget.org/packages/Abp.Dapper

And read the doc https://aspnetboilerplate.com/Pages/Documents/Dapper-Integration

if you still want to get a connection string you can get from config

ConfigurationManager.ConnectionStrings["Default"];

or you can create a custom repository and get it from DbContext

Upvotes: 1

Related Questions