When a stored procedure has multiple result sets with the same column signature, only the first rowset with the given signature is included in the generated DBML.
Consider the following three stored procedures:
123456789101112131415161718
CREATE PROCEDURE [GetOneWithLetters]
AS BEGIN
SELECT 1 as [One], [Letter] FROM [dbo].[Letters]
END
GO
CREATE PROCEDURE [GetTwoWithLetters]
AS BEGIN
SELECT 2 as [Two], [Letter] FROM [dbo].[Letters]
END
GO
CREATE PROCEDURE [BrokenInSqlMetal]
AS BEGIN
exec [GetOneWithLetters]
exec [GetTwoWithLetters]
END
GO
The first two stored procedures return simple result sets. The third stored procedure returns two result sets by calling first two procedures.
Note that although the [BrokenInSqlMetal] procedure returns two result sets, only one result is generated. When the stored procedure is executed via a LINQ to SQL DataContext, and reults are retrieved by calling DataContext.GetResult two times, the contents of the second result set are incorrect. The value of the One property (which should correspond to the [Two] column of the second stored proc) is not populated.
Resolution:
One fix is to swap the position of the columns in one of the rowsets. It also appears that adding a column alias to one of the child procedures will resolve the problem. Of course, this will likely require modifying the calling code at some layer of your application.
Connect:
I have posted this issue to Microsoft Connect. If it affects you, please visit and vote here.