I am using dapper to do some oracle access. I have a scenario where I have to have an output parameter with a type of OracleDbType.Clob. As I am using dapper and thus using the base DbType enumeration I am using the DbType.Object enum as suggested here http://docs.oracle.com/html/B14164_01/featOraCommand.htm to stand in for OracleDbType.Clob.
However, this sets the command parameter (deep down in dapper) to be of DbType object and oracle type Blob (as the DbConnection providers a concrete OracleParameter). The problem being this Oracle proc only works if this parameter is of type Clob not Blob.
The pure ADO code works like a charm (Using OracleParameter and OracleConnection etc) but there appears to be no way to set the concrete type or hook into this DbParameter creation process in dapper to change this OracleType on the returned CommandParameter?
This 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,
Jon