1

我创建了一个返回动态结果集的 SP,因此我创建了一个复杂类型,用于将结果集映射到实体。在执行此过程时,我遇到了异常

不存在从对象类型 System.Data.Objects.ObjectParameter 到已知托管提供程序本机类型的映射。

以下是EDMX自动创建的功能

 public int GetKpiComparisonResults(Nullable<global::System.Int32> p_primary_org_unit_surrogate_key, global::System.String p_org_unit_surrogate_key_csv, global::System.String p_industry_code, global::System.String p_country_code, Nullable<global::System.Boolean> p_period_type, Nullable<global::System.Int32> p_start_year, Nullable<global::System.Int32> p_end_year, Nullable<global::System.Int32> p_start_period, Nullable<global::System.Int32> p_end_period, ObjectParameter p_sql_errcode, ObjectParameter p_sql_errmsg)
        {
            //here i am declaring the parametrs
            return base.ExecuteFunction("GetKpiComparisonResults", p_primary_org_unit_surrogate_keyParameter, p_org_unit_surrogate_key_csvParameter, p_industry_codeParameter, p_country_codeParameter, p_period_typeParameter, p_start_yearParameter, p_end_yearParameter, p_start_periodParameter, p_end_periodParameter, p_sql_errcode, p_sql_errmsg);


        }

我需要复杂类型的结果。所以我改变了如下方法

   public ObjectResult<KpiComparisonResult> GetKpiComparisonResults(Nullable<global::System.Int32> p_primary_org_unit_surrogate_key, global::System.String p_org_unit_surrogate_key_csv, global::System.String p_industry_code, global::System.String p_country_code, Nullable<global::System.Boolean> p_period_type, Nullable<global::System.Int32> p_start_year, Nullable<global::System.Int32> p_end_year, Nullable<global::System.Int32> p_start_period, Nullable<global::System.Int32> p_end_period, ObjectParameter p_sql_errcode, ObjectParameter p_sql_errmsg)
        {
            //here i am declaring the parametrs
            return base.ExecuteStoreQuery<KpiComparisonResult>("GetKpiComparisonResults", p_primary_org_unit_surrogate_keyParameter, p_org_unit_surrogate_key_csvParameter, p_industry_codeParameter, p_country_codeParameter, p_period_typeParameter, p_start_yearParameter, p_end_yearParameter, p_start_periodParameter, p_end_periodParameter, p_sql_errcode, p_sql_errmsg);


        }

执行此方法时出现异常?如何在 EntityFramework 中管理动态结果集?

4

0 回答 0