首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EnterpriseLibrary 6.0 DAAB中带有引用光标的ExecuteSprocAccessor

EnterpriseLibrary 6.0 DAAB中带有引用光标的ExecuteSprocAccessor
EN

Stack Overflow用户
提问于 2013-06-25 23:48:19
回答 1查看 666关注 0票数 1

我使用的是VS2012,EnterpriseLibrary 6.0 DAAB。我与数据库Oracle的连接正常。

我有一个Oracle过程,它没有任何输入参数,只有输出参数,它的类型是RefCursor。

我可以通过使用Execute Reader和ExecuteDataset调用该过程来获得输出。

现在我正在尝试使用DatabaseExtension.ExecuteSprocAccessor。我得到了一个错误,它表明参数类型无效。

谁能为我提供一个使用ExecuteSprocAccessor的好例子。

谢谢

EN

回答 1

Stack Overflow用户

发布于 2013-07-03 00:23:09

//好消息//

我找到了问题的根本原因,它在Enterprise Library6.0中,即第66行的类CommandAccessor.cs中的DataBlock源代码中。

因为在命令对象中,参数集合不在那里。为了解决这个问题,我们需要在SprocAccessor.cs中执行以下操作,该方法位于第97行

在下面的方法中,命令对象在using语句中。因此,当命令超出using子句的作用域时,它将丢失其参数集合值。因此,我删除了using子句,它工作得很好。

代码语言:javascript
复制
/// <summary>
    /// Executes the stored procedure and returns an enumerable of <typeparamref name="TResult"/>.
    /// The enumerable returned by this method uses deferred loading to return the results.
    /// </summary>
    /// <param name="parameterValues">Values that will be interpret by an <see cref="IParameterMapper"/> and function as parameters to the stored procedure.</param>
    /// <returns>An enumerable of <typeparamref name="TResult"/>.</returns>
    public override IEnumerable<TResult> Execute(params object[] parameterValues)
    {
        /*
        using (DbCommand command = Database.GetStoredProcCommand(procedureName))
        {
            parameterMapper.AssignParameters(command, parameterValues);
            return base.Execute(command);
        }
        */
        DbCommand command = Database.GetStoredProcCommand(procedureName);
        parameterMapper.AssignParameters(command, parameterValues);
        return base.Execute(command);
    }

我现在很高兴,找到了根本原因。它现在运行得很好。产出就像子弹一样扑面而来。

谢谢

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17301841

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档