Is there a way to force OracleCommand.BindByName to be true by default for ODP.NET?

I didn't try it but,

I have seen something like

"cmd.GetType().GetProperty("BindByName").SetValue(cmd,true,null);" in PetaPoco.cs file.

Maybe it can help.


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
}

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


I had the same problem with SqlDataSource Update commands after porting ASPX code to Oracle.DataAcees.Client and solved it by changing OracleCommand.BindByName property in SqlDataSource OnUpdating handler like this:

protected void SqlDataSource_Updating(object sender, SqlDataSourceCommandEventArgs e)
{
    Oracle.DataAccess.Client.OracleCommand b_OracleCommand = 
                  (Oracle.DataAccess.Client.OracleCommand)e.Command;
    b_OracleCommand.BindByName = true;
}