Alright, I think I have reproduced what you ran into, but I can only conclude it did the right thing. So I created a stored procedure with 10 resultsets: (On northwind)
CREATE PROCEDURE [dbo].[pr_TenResultsets]
AS
BEGIN
SELECT * FROM Customers;
SELECT CustomerID From Customers;
SELECT DISTINCT Country FROM Customers;
SELECT DISTINCT City FROM Customers;
SELECT CompanyName FROM Customers;
SELECT DISTINCT Country, City FROM Customers;
SELECT CustomerId, Country, City FROM Customers;
SELECT CompanyName, CustomerId, Country FROM Customers;
SELECT CompanyName, CustomerId, Country, City FROM Customers;
SELECT CompanyName, City FROM Customers;
END
Then I added the proc to my test project, mapped 10 typed views on these 10 resultsets. This was all as expected, Typedview10 was mapped onto resultset 10. I generated code into a new folder and everything was defined ok, resultsets were correctly assigned.
Now I altered the stored procedure to this:
ALTER PROCEDURE [dbo].[pr_TenResultsets]
AS
BEGIN
SELECT * FROM Customers;
SELECT CompanyName, City FROM Customers;
SELECT CustomerID From Customers;
SELECT DISTINCT Country FROM Customers;
SELECT DISTINCT City FROM Customers;
SELECT CompanyName FROM Customers;
SELECT DISTINCT Country, City FROM Customers;
SELECT CustomerId, Country, City FROM Customers;
SELECT CompanyName, CustomerId, Country FROM Customers;
SELECT CompanyName, CustomerId, Country, City FROM Customers;
END
So I moved the 10th resultset to spot 2. I then synced the project, and this made the designer to map the typed views to different resultsets as the resultsets are now different; resultset2 is now equal to resultset10 previously. So Typedview1 is still mapped to resultset 1, but typedview2 is now mapped to resultset3 (as the resultset3 was previously resultset2), TypedView3 is now mapped to resultset4 etc. and TypedView10 is now mapped to resultset2 (as the 10th resultset originally is now resultset2 of the stored proc.
Generated code again and it is doing it correctly:
/// <summary>Gets the SP Call using query for fetching the TenResultsetsResultset10TypedView TypedView.</summary>
/// <returns>ready to use IRetrievalQuery instance for fetching the typedview</returns>
/// <remarks>Output parameters are not set after query is executed</remarks>
public static IRetrievalQuery GetQueryForTenResultsetsResultset10TypedViewTypedView()
{
IRetrievalQuery query = GetTenResultsetsCallAsQuery();
query.ResultsetNumber = 2;
return query;
}
What I think might be wrong on your side is that the code calls a stored procedure in a schema which has still the original ordering of the resultsets (so in my example, the order when I created the proc) but the generated code expects them to be in a different order, resulting in the wrong resultset being used.
Could that be the case here?