Search code examples
aspnetboilerplate

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?


Solution

  • 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