Is it safe to share OracleConnection to execute many OracleCommands concurrently?

222 Views Asked by At

I'm trying to avoid to open and close the connection for each command with the intention of improve performance, the list of commands is really huge. Testing mannually this approach appears to work well, but I couldn't find at Oracle Docs any mention if it is valid or thread unsafe. Could anyone confirm if is it Ok ?

OracleCommand[] commands = CreateOracleCommands();

using var conn = CreateOracleConnection();

Parallel.ForEach(commands, options, async cmd =>
{
    cmd.Connection = conn;
    cmd.ExecuteNonQuery();
});

I'm using asp.net core MVC 3.1 with Oracle.ManagedDataAccess.Core 2.19.70.

0

There are 0 best solutions below