using System.Data.Common;
using e_suite.Database.SqlServer;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Configuration;

namespace e_suite.Service.EFlowSync.Repository;

public class SqlRepositoryBase : IDisposable
{
    protected DbConnection Connection { get; }

    public SqlRepositoryBase(IConfiguration configuration)
    {
        var connectionString = ESuiteDatabaseExtension.BuildConnectionString(configuration);
        
        Connection = new SqlConnection(connectionString);
    }

    public void Dispose()
    {
        GC.SuppressFinalize(this);
        Connection.Close();
    }
}