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
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
C#:
Figure 20
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
C#:
Figure 22