-1

I have this class that connects to my oracle database:

public class Conexao : IDisposable
{
    private readonly IOptions<Configuracao> _config;
    public OracleConnection ConexaoOra{ get; internal set; }
    private OracleTransaction _transacao;
    private bool _finalized;
    private bool _commited;
    private const string CONNECTION_STRING = "myConnectionString";


    public Conexao(IOptions<Configuracao> config)
    {
        _config = config;
        _finalized = false;
        _commited = false;
        ConexaoOra = new OracleConnection();
        ConexaoOra.ConnectionString = CONNECTION_STRING;
        ConexaoOra.Open();
    }

  
    ~Conexao()
    {
        Dispose();
    }

    public void BeginTransaction(System.Data.IsolationLevel level = System.Data.IsolationLevel.ReadCommitted)
    {
        _transacao = ConexaoOra.BeginTransaction(level);
    }

    public void Commit()
    {
        if (_transacao != null)
        {
            _transacao.Commit();
            _transacao = null;
        }
        _commited = true;
    }

}

This class is instantiated every time any transaction is triggered in the DAL class

sample:

   using ((conexao == null ? conexao = new Conexao() : conexao))
   OracleCommand oracleCommand = new OracleCommand("", conexao.ConexaoOra);
   //... 

The Json Settings File and the Connection Class are in different projects in the same solution

how to load in this line my connectionString of appSettings Json File?

       private const string CONNECTION_STRING = "myConnectionString";
joeyanthon
  • 208
  • 1
  • 2
  • 13
  • Tag the question with `C#`, not `C`. – rdxdkr Apr 09 '21 at 18:54
  • Does this answer your question? [How to read AppSettings values from a .json file in ASP.NET Core](https://stackoverflow.com/questions/31453495/how-to-read-appsettings-values-from-a-json-file-in-asp-net-core) – paulsm4 Apr 09 '21 at 18:59

1 Answers1

2

Sorry, I took the example from an old project where I used ServiceStack and it probably had some helpers to ease the procedure. With just plain .NET it seems to be more tedious, so have a look here and here.

rdxdkr
  • 839
  • 1
  • 12
  • 22