【发布时间】:2015-05-27 16:16:20
【问题描述】:
我已按照使用 Entity Framework 在存储过程中返回多个结果集的指南进行操作。在这里找到:
- https://msdn.microsoft.com/en-us/data/jj691402.aspx?f=255&MSPPError=-2147217396
- http://www.binaryintellect.net/articles/30738a7c-5176-4333-aa83-98eab8548da5.aspx
- http://www.codeproject.com/Articles/675933/Returning-Multiple-Result-Sets-from-an-Entity-Fram?msg=5026933#xx5026933xx
但是,如果返回第三个结果集,在客户端代码调用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