tycg_carviolation_BE/Traffic.Repository/Infrastructures/ConnectionFactory.cs

30 lines
757 B
C#
Raw Permalink Normal View History

using Microsoft.Extensions.Configuration;
using MySql.Data.MySqlClient;
using System.Data.Common;
using System.Data.SqlClient;
namespace Traffic.Repository.Infrastructures
{
public class ConnectionFactory
{
private readonly IConfiguration _configuration;
public ConnectionFactory(IConfiguration configuration)
{
_configuration = configuration;
}
public DbConnection CreateDbConn()
{
return new MySqlConnection(GetConnectionString());
}
private string GetConnectionString()
{
//return _configuration.GetConnectionString("DefaultConnection");
return _configuration["ConnectionStrings:DefaultConnection"];
}
}
}