39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Extensions.Configuration;
|
|
using MySqlConnector;
|
|
|
|
namespace ConsoleTemplate.Contexts
|
|
{
|
|
internal class MysqlDBContext : IDBContext
|
|
{
|
|
private IConfiguration _config;
|
|
private MySqlConnection _connection;
|
|
private MySqlCommand _cmd;
|
|
private string _connectionStringRead;
|
|
private string _connectionStringWrite;
|
|
|
|
public MysqlDBContext(IConfiguration configuration)
|
|
{
|
|
_config = configuration;
|
|
_connectionStringRead = _config.GetConnectionString("ReadDB").ToString();
|
|
_connectionStringWrite = _config.GetConnectionString("WriteDB").ToString();
|
|
}
|
|
|
|
public Object GetReadConn()
|
|
{
|
|
_connection = new MySqlConnection(_connectionStringWrite);
|
|
return _connection;
|
|
}
|
|
|
|
public Object GetWriteConn()
|
|
{
|
|
_connection = new MySqlConnection(_connectionStringRead);
|
|
return _connection;
|
|
}
|
|
}
|
|
}
|