More than 2 result sets in stored procedure

c# entity-framework-6 stored-procedures

Question

I have followed the guidance for returning more than 1 resultset in a stored procedure with Entity Framework. Found here:

However if a 3rd resultset is returned, after the client code calls the GetNextResult<T> there is an error:

The type parameter 'db.GetShippingItems' in ExecuteFunction is incompatible with the type 'db.GetProductDetails' returned by the function.

GetProductDetails is the 2nd return type. The first is GetProduct. I added a 3rd ResultMapping to the FunctionImportMapping element in the .edmx file.

The FunctionImport is as follows:

<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>
1
0
8/17/2015 4:23:57 AM

Popular Answer

To get third resultset you need to use the GetNextResults() for the second resultset etc.

//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

1
8/19/2015 3:12:58 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow