实体框架 - 具有多个结果集的存储过程 - 没有行返回

时间:2022-01-04 00:41:44

so, i was trying to implement a stored procedure with multiple results sets in entity framework. it all seemed to be too easy. but, i am not getting any rows for my results sets (even though, it seems i do get the result sets themselves back).

所以,我试图在实体框架中实现具有多个结果集的存储过程。这一切似乎太容易了。但是,我没有为我的结果集获取任何行(尽管,似乎我确实得到了结果集本身)。

What i have done:

我做了什么:

  1. created the stored procedure which returns 3 result sets
  2. 创建了返回3个结果集的存储过程
  3. Created the complex type that represents the return values
  4. 创建表示返回值的复杂类型
  5. manually edited the edmx file as per Stored Procedures with Multiple Result Sets
  6. 根据具有多个结果集的存储过程手动编辑edmx文件
  7. Failed with 3 and tried the code version from the same page, still no rows back.
  8. 失败3并尝试从同一页面的代码版本,仍然没有回来的行。
  9. Reverted the code back to 3.
  10. 将代码还原为3。

my edmx file (related content only):

我的edmx文件(仅限相关内容):

  <FunctionImport Name="getGlobalReport2">
    <ReturnType Type="Collection(MTModel.GlobalReport2)"/>
    <ReturnType Type="Collection(MTModel.GlobalReport2)"/>
    <ReturnType Type="Collection(MTModel.GlobalReport2)"/>
    <Parameter Name="regions" Mode="In" Type="String" />
    <Parameter Name="countries" Mode="In" Type="String" />
    <Parameter Name="companySizes" Mode="In" Type="String" />
    <Parameter Name="products" Mode="In" Type="String" />
  </FunctionImport>

  <FunctionImportMapping FunctionImportName="getGlobalReport2" FunctionName="MTModel.Store.getGlobalReport2" >
    <ResultMapping>
      <ComplexTypeMapping TypeName="MTModel.GlobalReport2" />
    </ResultMapping>
    <ResultMapping>
      <ComplexTypeMapping TypeName="MTModel.GlobalReport2" />
    </ResultMapping>
    <ResultMapping>
      <ComplexTypeMapping TypeName="MTModel.GlobalReport2" />
    </ResultMapping>
  </FunctionImportMapping>

my code:

我的代码:

var x = mtEntities.getGlobalReport2(regions, countries, companySizes, products);
Response.Write(x.Count());

var y = x.GetNextResult<GlobalReport2>();
Response.Write(y.Count());

var z = x.GetNextResult<GlobalReport2>();

What i have allready checked:

我已经检查了什么:

  1. Checked that the server receives the request as per How can I view live MySQL queries?
  2. 检查服务器是否按照我的方式接收请求如何查看实时MySQL查询?
  3. Run the query i grabbed from the server and made sure it returns result sets and rows
  4. 运行我从服务器抓取的查询,并确保它返回结果集和行
  5. Debug the app to see there are no Exceptions i missed on the way
  6. 调试应用程序,看看在途中我没有错过任何例外

There seems to be no issue with the call, or the app, except that no rows are returned. Any suggestions?

除了没有返回任何行外,调用或应用程序似乎没有问题。有什么建议么?

EDIT: as per your comments about the edmx being overwritten, that would happen only if i regenerate the model from the database, not if i update it. i wouldn't expect anything else, since its regenerating the model.

编辑:根据你对edmx被覆盖的评论,只有当我从数据库重新生成模型时才会发生这种情况,而不是我更新它。我不会指望任何其他东西,因为它重新生成模型。

1 个解决方案

#1


4  

Dont you think you should have some property defined for your complex types you have created ? For example:

你认为你应该为你创建的复杂类型定义一些属性吗?例如:

<FunctionImportMapping FunctionImportName="GetGrades" 
                       FunctionName="SchoolModel.Store.GetGrades" >
  <ResultMapping>
    <ComplexTypeMapping TypeName="SchoolModel.GradeInfo">
      <ScalarProperty Name="EnrollmentID" ColumnName="enroll_id"/>
      <ScalarProperty Name="CourseID" ColumnName="course_id"/>
      <ScalarProperty Name="StudentID" ColumnName="student_id"/>
      <ScalarProperty Name="Grade" ColumnName="grade"/>
    </ComplexTypeMapping>
  </ResultMapping>
</FunctionImportMapping>

Check this too

检查一下

Also as rightly stated by Mike in the comment to your question, if you in future update your edmx file, if it's regenerated you're going to lose to customizations.

另外正如Mike在您的问题评论中正确陈述的那样,如果您将来更新您的edmx文件,如果它重新生成,您将失去自定义。

#1


4  

Dont you think you should have some property defined for your complex types you have created ? For example:

你认为你应该为你创建的复杂类型定义一些属性吗?例如:

<FunctionImportMapping FunctionImportName="GetGrades" 
                       FunctionName="SchoolModel.Store.GetGrades" >
  <ResultMapping>
    <ComplexTypeMapping TypeName="SchoolModel.GradeInfo">
      <ScalarProperty Name="EnrollmentID" ColumnName="enroll_id"/>
      <ScalarProperty Name="CourseID" ColumnName="course_id"/>
      <ScalarProperty Name="StudentID" ColumnName="student_id"/>
      <ScalarProperty Name="Grade" ColumnName="grade"/>
    </ComplexTypeMapping>
  </ResultMapping>
</FunctionImportMapping>

Check this too

检查一下

Also as rightly stated by Mike in the comment to your question, if you in future update your edmx file, if it's regenerated you're going to lose to customizations.

另外正如Mike在您的问题评论中正确陈述的那样,如果您将来更新您的edmx文件,如果它重新生成,您将失去自定义。