matthewbaskey
matthewbaskey

Reputation: 1037

More than 2 result sets in stored procedure

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>

Upvotes: 0

Views: 1114

Answers (1)

Alexander Pashkov
Alexander Pashkov

Reputation: 21

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

Upvotes: 1

Related Questions