简体   繁体   English

如何使.Net Oracle.DataAccess.dll(ODP)像MS一样提供工作

[英]How to get .Net Oracle.DataAccess.dll (ODP) to work like MS provided equivalent

Can anyone help me with an Oracle DataAccess related issue? 谁能帮助我解决与Oracle DataAccess相关的问题?

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. 我们有一个遗留应用程序(C#.net3.5),该应用程序连接到Oracle或Sql Server数据库,并且迄今为止,对于Oracle,该应用程序已经使用Microsoft提供的System.Data.OracleClient命名空间来存储诸如DataAdapters等之类的东西。与Sql Server相比,DataAdapter.Fill()方法非常慢(大约一个数量级),并且客户大声抱怨。

So in an attempt to address this, we switched to the Oracle-supplied Oracle.DataAccess.Client namespace/library (Oracle 11g ODP client). 因此,为了解决这个问题,我们切换到Oracle提供的Oracle.DataAccess.Client名称空间/库(Oracle 11g ODP客户端)。 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. 但是,现在枚举类型值还有许多其他问题,而MS提供的Oracle库却没有。 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). 使用MS Oracle材料(或MS Sql Server材料),我在下面标记的行正确地将枚举值转换为其基础数据值(例如,testEnums.Value0变为0)。 With the Oracle library it doesn't - an exception is thrown. 对于Oracle库,它不是-引发异常。 The problem appears to be in the code sample below, with the IDbParameter object returned by cmd.CreateParameter(). 问题似乎出在下面的代码示例中,其中IDbParameter对象由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) (TryGetParameterValue(...)仅返回当前值不变,如果parameter.Value == null,则返回DBNull。cmd将为Oracle.DataAccess.Client.OracleCommand或Sstem.Data.OracleClient.OracleCommand,具体取决于哪个dll。被引用)

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 TIA

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. 自从MS宣布终止对Oracle提供商的支持,并且Oracle的提供商陷入了极大的痛苦之后,我便将一切都转移给了第三方开发商Devart。 They have a great tool called Dot Connect for Oracle. 他们有一个很棒的工具叫做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. 它并不昂贵,并且支持直接模式,这使您不必安装Oracle客户端或与TNSNAMES混在一起。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM