When a stored procedure can return multiple result shapes,
the return type of the SPROC method on the DataContext cannot be strongly typed
to a single class shape. For example, consider the SPROC below which
returns either a product result or an order result depending on the input
parameter:
Figure 18
![](/ArticleFiles/1430/image018.jpg)
LINQ to SQL supports the ability to create
SPROC helper methods that can return either a Product or Order shape by adding
a partial "NorthwindDataContext" class to the project that defines
a method (which in this case we'll call "VariablesShapeSample")
that invokes the SPROC and returns an IMultipleResult object like so:
VB:
Figure 19
![](/ArticleFiles/1430/image019.jpg)
C#:
Figure 20
![](/ArticleFiles/1430/image020.jpg)
Once this method is added into our project we
can then call it and convert the result to be either a Product or Order
sequence when we are using it:
VB:
Figure 21
![](/ArticleFiles/1430/image021.jpg)
C#:
Figure 22
![](/ArticleFiles/1430/image022.jpg)