有没有办法强制OracleCommand.BindByName默认情况下,ODP.NET是真的吗? [英] Is there a way to force OracleCommand.BindByName to be true by default for ODP.NET?

查看:700
本文介绍了有没有办法强制OracleCommand.BindByName默认情况下,ODP.NET是真的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于<一href="http://msdn.microsoft.com/en-us/library/system.data.oracleclient.aspx">System.Data.OracleClient库已<一个href="http://blogs.msdn.com/adonet/archive/2009/06/15/system-data-oracleclient-update.aspx">de$p$pcated,我们在我们的迁移code基使用的Oracle数据提供.NET <过程/ A>(ODP.NET)来代替。其中一个是我们遇到的问题是,System.Data.OracleClient的使用参数名绑定,而不是按位置绑定,所有的$ C $了C直接访问<一href="http://msdn.microsoft.com/en-us/library/system.data.oracleclient.oraclecommand.aspx">System.Data.OracleClient.OracleCommand相对于使用的中间数据层

Since the System.Data.OracleClient library has been deprecated, we are in the process of migrating our code base to use Oracle Data Provider for .NET (ODP.NET) instead. One of the issues that we have encountered is that the System.Data.OracleClient uses parameter name binding as opposed to binding by position and all of the code directly access the System.Data.OracleClient.OracleCommand as opposed to using an intermediate data layer.

由于有相当多的code,有一个简单的方法来迫使ODP.NET OracleCommand.BindByName被默认为true,或者我们必须经历,它在每次使用时设定的值?拜倒在那,有没有一种简单的方法来插入该行的code在Visual Studio 2008?

Since there is quite a bit of code, is there an easy way to force the ODP.NET OracleCommand.BindByName to be true by default, or must we go through and set the value each time that it is used? Failing at that, is there an easy way to insert that line of code in Visual Studio 2008?

推荐答案

我知道这个线程是老了,但今天我有同样的问题,以为我会分享我的情况下,其他人有这个问题的解决方案。由于的OracleCommand是密封的(它很烂),我创建了一个新的类,它封装的OracleCommand时,BindByName设置为true的实例。下面是执行工作的一部分:

I know this thread is old, but I had the same problem today and thought I would share my solution in case someone else had this problem. Since OracleCommand is sealed (which sucks), I created a new class that encapsulates the OracleCommand, setting the BindByName to true on instantiation. Here's part of the implementation:

public class DatabaseCommand
{
    private OracleCommand _command = null;

    public DatabaseCommand(string sql, OracleConnection connection)
    {
        _command = new OracleCommand(sql, connection)
        {
            BindByName = true
        };
    }

    public int ExecuteNonQuery()
    {
        return _command.ExecuteNonQuery();
    }

    // Rest of impl removed for brevity
}

然后,所有我必须做清理的命令是做搜索的OracleCommand并更换DatabaseCommand和测试。

Then all I had to do to cleanup the commands was do a search for OracleCommand and replace with DatabaseCommand and test.

这篇关于有没有办法强制OracleCommand.BindByName默认情况下,ODP.NET是真的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆