How would one go about using Dapper with Oracle stored procedures which return cursors?
var p = new DynamicParameters();
p.Add("foo", "bar");
p.Add("baz_cursor", dbType: DbType.? , direction: ParameterDirection.Output);
Here, the DbType is System.Data.DbType which does not have a Cursor member. I've tried using DbType.Object but that does not work with both OracleClient and OracleDataAcess.
What would be a possible way to use OracleType or OracleDbType instead?
You would have to implement:
Then in the
AddParameters
callback you would cast theIDbCommand
to anOracleCommand
and add the DB specific params.Just to elaborate on Sams suggestion here's what I came up with. Note that this code is brittle and is now just for Oracle.
Modified Dapper 1.7
Test code
Thanks for the solution here. I achieved the same thing with a little less code using a simple DynamicParameter decorator:
Add this class to your project
and your code should like below :-