I’ve got a class called Databaseprovider and there I have a static OracleTransaction property called CurrentTransaction. Here’s how I assign value to it:
OracleConnection connection = ConnectionProvider.CreateConnection(conString);
connection.Open();
DatabaseProvider.CurrentTransaction = connection.BeginTransaction(IsolationLevel.ReadCommitted);
I’ve just noticed that after Commit or Rollback the connection property of my transactions gets set to null. Now I wonder what happens to the OracleConnection object I created before? Does it get Closed and disposed too, or it becomes a free, unreachable object?
The connection remains open until the code has
.Close().Instead of the above code, write the code with
usingblock.Initialize the expensive objects when needed, dispose it off after the use.