I am using dapper to access oracle. I have a scenario where I should have an output parameter of type OracleDbType.Clob. Since I am using dapper and thus using the basic DbType enum, I am using the DbType.Object enumeration as suggested here http://docs.oracle.com/html/B14164_01/featOraCommand.htm to get up for OracleDbType.Clob.
However, this sets the command parameter (deep in dapper) for the DbType object and the oracle Blob type (since the DbConnection providers are a specific OracleParameter). The problem is that this Oracle process only works if this parameter is of type Clob not Blob.
Pure ADO code works like a charm (using OracleParameter and OracleConnection, etc.), but there seems to be no way to set a specific type or intercept this DbParameter creation process in dapper to change this OracleType type on the returned CommandParameter?
It works:
using (OracleConnection conn = new OracleConnection("some connection string")) { conn.Open(); var cmd = new OracleCommand("ProcName", conn); cmd.CommandType = CommandType.StoredProcedure; var paramOne = new OracleParameter("ReturnValue", OracleDbType.Clob, int.MaxValue, null, ParameterDirection.Output); cmd.Parameters.Add(paramOne); cmd.ExecuteNonQuery(); var value1 = paramOne.Value; }
This fails:
DynamicParameters dyanmicParameters = new DynamicParameters(); dyanmicParameters.Add("ReturnValue", null, DbType.Object, ParameterDirection.Output); connection.Execute("ProcName", dyanmicParameters, commandType: CommandType.StoredProcedure); var val = dynamicParameters.Get<object>("ReturnValue");
Any ideas?
Thanks,
John
source share