实体框架过程错误 - Silverlight、EF、Oracle

发布于 2025-01-07 12:59:29 字数 1001 浏览 3 评论 0原文

错误信息: 存储数据提供程序返回的数据读取器没有足够的列来满足所请求的查询。

public ObjectResult<global::System.String> P_GET_MST_CODE(global::System.String i_RES_TYPE, ObjectParameter v_RESULT)
{
    ObjectParameter i_RES_TYPEParameter;
    if (i_RES_TYPE != null)
    {
        i_RES_TYPEParameter = new ObjectParameter("I_RES_TYPE", i_RES_TYPE);
    }
    else
    {
        i_RES_TYPEParameter = new ObjectParameter("I_RES_TYPE", typeof(global::System.String));
    }

    return base.ExecuteFunction<global::System.String>("P_GET_MST_CODE", i_RES_TYPEParameter, v_RESULT);
}

下面是存储过程的定义。

<Function Name="P_GET_MST_CODE" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="LEGACY">
  <Parameter Name="I_RES_TYPE" Type="varchar2" Mode="In" />
  <Parameter Name="V_RESULT" Type="varchar2" Mode="Out" />
</Function>

谁能帮我解决这个问题?

Error Message:
The data reader returned by the store data provider does not have enough columns for the query requested.

public ObjectResult<global::System.String> P_GET_MST_CODE(global::System.String i_RES_TYPE, ObjectParameter v_RESULT)
{
    ObjectParameter i_RES_TYPEParameter;
    if (i_RES_TYPE != null)
    {
        i_RES_TYPEParameter = new ObjectParameter("I_RES_TYPE", i_RES_TYPE);
    }
    else
    {
        i_RES_TYPEParameter = new ObjectParameter("I_RES_TYPE", typeof(global::System.String));
    }

    return base.ExecuteFunction<global::System.String>("P_GET_MST_CODE", i_RES_TYPEParameter, v_RESULT);
}

Below is the definition of the stored procedure.

<Function Name="P_GET_MST_CODE" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="LEGACY">
  <Parameter Name="I_RES_TYPE" Type="varchar2" Mode="In" />
  <Parameter Name="V_RESULT" Type="varchar2" Mode="Out" />
</Function>

Can anyone help me to solve this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青瓷清茶倾城歌 2025-01-14 12:59:29

我通过避免实体连接对象解决了这个问题。 :-)

到目前为止,ORACLE 数据库的 OUT 参数似乎不支持。

以下是更改后的代码示例。

using System.Data;
using System.Data.Common;
using System.Data.EntityClient;
using System.ServiceModel.DomainServices.EntityFramework;
using System.ServiceModel.DomainServices.Server;
using Oracle.DataAccess.Client;

.......

[Invoke]
public string method(string OTL)
{
    DbCommand cmd = (((EntityConnection)this.ObjectContext.Connection).StoreConnection).CreateCommand();
    cmd.CommandType = System.Data.CommandType.StoredProcedure;
    cmd.CommandText = "LoveMe";

    OracleParameter ep = new OracleParameter("I_RES_TYPE", OTL);
    ep.OracleDbType = OracleDbType.Varchar2;
    ep.Direction = ParameterDirection.Input;

    OracleParameter epV_RESULT = new OracleParameter("V_RESULT", null);
    epV_RESULT.OracleDbType = OracleDbType.Varchar2;
    epV_RESULT.Size = 30;
    epV_RESULT.Direction = ParameterDirection.Output;

    cmd.Parameters.Add(ep);
    cmd.Parameters.Add(epV_RESULT);

    cmd.Connection.Open();
    cmd.ExecuteNonQuery();

    string result = cmd.Parameters[1].Value.ToString(); //What I want to get.

    cmd.Connection.Close();

    return result;
}

I've solved this by avoiding entity connection object. :-)

Until now, It seems to be unsupported for OUT Parameter of ORACLE Database.

Below is the changed code example.

using System.Data;
using System.Data.Common;
using System.Data.EntityClient;
using System.ServiceModel.DomainServices.EntityFramework;
using System.ServiceModel.DomainServices.Server;
using Oracle.DataAccess.Client;

.......

[Invoke]
public string method(string OTL)
{
    DbCommand cmd = (((EntityConnection)this.ObjectContext.Connection).StoreConnection).CreateCommand();
    cmd.CommandType = System.Data.CommandType.StoredProcedure;
    cmd.CommandText = "LoveMe";

    OracleParameter ep = new OracleParameter("I_RES_TYPE", OTL);
    ep.OracleDbType = OracleDbType.Varchar2;
    ep.Direction = ParameterDirection.Input;

    OracleParameter epV_RESULT = new OracleParameter("V_RESULT", null);
    epV_RESULT.OracleDbType = OracleDbType.Varchar2;
    epV_RESULT.Size = 30;
    epV_RESULT.Direction = ParameterDirection.Output;

    cmd.Parameters.Add(ep);
    cmd.Parameters.Add(epV_RESULT);

    cmd.Connection.Open();
    cmd.ExecuteNonQuery();

    string result = cmd.Parameters[1].Value.ToString(); //What I want to get.

    cmd.Connection.Close();

    return result;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文