DbParameter值无法转换为OracleRefCursor:C#错误 [英] DbParameter value cannot be converted to OracleRefCursor : C# error

查看:186
本文介绍了DbParameter值无法转换为OracleRefCursor:C#错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从给定的参数对象创建一个读取器,同时尝试将"ref cursor"输出解析为C#中的属性对象.如下所示_getDataReaderMethod变为null,无法继续.

输入:command.Parameters [readerCursorName]作为dbParameter发送到GetDataReader方法

I am trying to create a reader from the given parameter object while trying to parse the ''ref cursor'' output to property object in C#. _getDataReaderMethod as below becomes null and could''t proceed.

Input: command.Parameters[readerCursorName] sent as dbParameter to GetDataReader method

private static MethodInfo _getDataReaderMethod;
...
...
public DbDataReader GetDataReader(DbParameter dbParameter)
...
...
// Get the value for the parameter ie the ref cursor
object refCursor = dbParameter.Value;
_getDataReaderMethod = refCursor.GetType().GetMethod("GetDataReader");



_getDataReaderMethod变为" null" ,并且无法继续进行操作以返回DbDataReader.



_getDataReaderMethod becomes ''null'' and couldn''t proceed further to return the DbDataReader.

returnValue = _getDataReaderMethod.Invoke(dbParameter.Value, null);



注意:内部异常说"base {System.SystemException} = {方法只能在Type.IsGenericParameter为true的Type上调用."}''

有什么建议请.在此先感谢您.



Note: An inner exception says ''base {System.SystemException} = {"Method may only be called on a Type for which Type.IsGenericParameter is true."}''

Any suggestions please. Thanks in advance.

推荐答案

我花了很多时间,终于找到了导致我自己的根源,

I spent many hours on it, finally found the root cause myself,

OracleCommand oracleCommand = command as OracleCommand;
oracleCommand.ArrayBindCount = some_collection_object.Count;



由于我已经启用了将数组绑定到输入参数的功能,因此输出ref_cursor也已成为导致此问题的数组类型.



Since I had enabled the array binding to the input parameters, the output ref_cursor also had become array type which caused this problem.


这篇关于DbParameter值无法转换为OracleRefCursor:C#错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆