使用它返回游标小巧玲珑与Oracle存储过程游标、小巧玲珑、存储过程、使用它

2023-09-02 23:46:32 作者:怹

如何将一去使用精致小巧与返回游标Oracle存储过程?

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);

下面,所述的DbType是的System.Data.DbType不具有一个光标构件。我已经使用DbType.Object尝试,但并不既OracleClient的和OracleDataAcess工作。

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.

什么是使用OracleType或OracleDbType一个可行的办法呢?

What would be a possible way to use OracleType or OracleDbType instead?

推荐答案

您必须实现:

 public interface IDynamicParameters
 {
    void AddParameters(IDbCommand command, Identity identity);
 }

然后在 AddParameters 回调,你会投 IDbCommand的的OracleCommand 并添加DB具体PARAMS。

Then in the AddParameters callback you would cast the IDbCommand to an OracleCommand and add the DB specific params.