【问题标题】:More than 2 result sets in stored procedure存储过程中超过 2 个结果集
【发布时间】:2015-05-27 16:16:20
【问题描述】:

我已按照使用 Entity Framework 在存储过程中返回多个结果集的指南进行操作。在这里找到:

但是,如果返回第三个结果集,在客户端代码调用GetNextResult<T> 之后会出现错误:

ExecuteFunction 中的类型参数“db.GetShippingItems”与函数返回的类型“db.GetProductDetails”不兼容。

GetProductDetails 是第二个返回类型。第一个是GetProduct。我在.edmx 文件中的FunctionImportMapping 元素中添加了第三个ResultMapping。

FunctionImport如下:

<FunctionImport Name="GetProduct">
   <ReturnType Type="Collection(db.GetProduct)" />
   <ReturnType Type="Collection(db.GetProductDetails)" />
   <ReturnType Type="Collection(db.GetProductShippingItems)" />
   <Parameter Name="ProgId" Mode="In" Type="Int32" />
</FunctionImport>

【问题讨论】:

  • 大师,你找到解决这个问题的方法了吗?我也面临同样的问题。
  • 不,我刚刚编写了 2 个存储过程,每个存储过程内部有 2 个结果集。我没有更多时间花在上面了。

标签: c# stored-procedures entity-framework-6


【解决方案1】:

要获得第三个结果集,您需要将 GetNextResults() 用于第二个结果集等。

//Get second result set
var products = results.GetNextResult<Product_SprocResult>();
categProd.Products.AddRange(products);

//Get third result set
var statuTypes = products.GetNextResult<StatusType_SprocResult>();                
categProd.StatusTypes.AddRange(statuTypes);

http://www.codeproject.com/Articles/675933/Returning-Multiple-Result-Sets-from-an-Entity-Fram?msg=5034933#xx5034933xx

【讨论】:

  • 这里非常不鼓励仅链接的答案,因为这些链接将来可能会失效。我建议您使用您引用的来源中的引用来编辑您的答案。
  • 我没有尝试 var 但我确实转换为第三组的 Complex_ResultType。这是不久前的事了。我将不得不深入研究程序的那一部分。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-04-22
  • 1970-01-01
  • 2013-10-06
  • 1970-01-01
  • 2019-11-08
  • 1970-01-01
相关资源
最近更新 更多