Reputation: 4850
Can anyone help me with an Oracle DataAccess related issue?
We have a legacy application (C#. .net3.5) which connects to Oracle or Sql Server databases, and which heretofore for Oracle has used the Microsoft supplied System.Data.OracleClient namespace for stuff like DataAdapters etc. What we have found is that the DataAdapter.Fill() method is very slow (by roughly an order of magnitude) in comparison to the Sql Server counterpart, and customers are complaining loudly.
So in an attempt to address this, we switched to the Oracle-supplied Oracle.DataAccess.Client namespace/library (Oracle 11g ODP client). Instant improvement by about an order of magnitude!
However we are now having a lot of other problems with enumerated type values which we didn't get with the MS-supplied Oracle library. The following code is deep in a utility library we use that knows nothing of the client application enums; the values are passed down as objects. Using the MS Oracle stuff (or the MS Sql Server stuff), the line I have marked below correctly transforms an enum value to its underlying data value (eg testEnums.Value0 becomes 0). With the Oracle library it doesn't - an exception is thrown. The problem appears to be in the code sample below, with the IDbParameter object returned by cmd.CreateParameter().
private static void SetParameter(IProvider provider, IDbCommand cmd, int parameterSet, KeyValuePair<string, object> parameter)
{
// Get the value. Not all values require a parameter.
object value;
if (TryGetParameterValue(parameter.Value, out value))
{
// Create the parameter
IDbDataParameter dbParameter = cmd.CreateParameter();
dbParameter.ParameterName = provider.CreateNameParameterName(parameter.Key, parameterSet);
dbParameter.Value = value; <---this line is problematic
...
( TryGetParameterValue(...) only returns the current value unchanged, or DBNull if parameter.Value == null. cmd will either be an Oracle.DataAccess.Client.OracleCommand or Sstem.Data.OracleClient.OracleCommand, depending on which dll is being referenced)
How can I overcome this without having to cast every enum value to its raw datatype in the client application (which requires changing thousands of lines of code)?
TIA
Upvotes: 1
Views: 696
Reputation: 56
I feel your pain. Since MS announced an end to support for Oracle providers and Oracle's providers are a huge pain in the butt, I've switched everything to a third-party vendor called Devart. They have a great tool called Dot Connect for Oracle. It's not terribly expensive and supports what they call direct mode, which allows you to not have to install Oracle client or mess with TNSNAMES.
Upvotes: 1