IMultipleResults.GetResult<TElement> Method ()

 

Retrieves the next result as a sequence of a specified type.

Namespace:   System.Data.Linq
Assembly:  System.Data.Linq (in System.Data.Linq.dll)

IEnumerable<TElement> GetResult<TElement>()

Return Value

Type: System.Collections.Generic.IEnumerable<TElement>

An enumeration for iterating over the results.

Type Parameters

TElement

The type of the sequence to be returned.

You would use code similar to the following to execute this stored procedure.

System_CAPS_noteNote

You must use the GetResult<TElement> pattern to obtain an enumerator of the correct type, based on your knowledge of the stored procedure.

Northwnd db = new Northwnd(@"c:\northwnd.mdf");

// Assign the results of the procedure with an argument
// of (1) to local variable 'result'.
IMultipleResults result = db.VariableResultShapes(1);

// Iterate through the list and write results (the company names)
// to the console.
foreach(VariableResultShapesResult1 compName in
    result.GetResult<VariableResultShapesResult1>())
{
    Console.WriteLine(compName.CompanyName);
}

// Pause to view company names; press Enter to continue.
Console.ReadLine();

// Assign the results of the procedure with an argument
// of (2) to local variable 'result'.
IMultipleResults result2 = db.VariableResultShapes(2);

// Iterate through the list and write results (the order IDs)
// to the console.
foreach (VariableResultShapesResult2 ord in
    result2.GetResult<VariableResultShapesResult2>())
{
    Console.WriteLine(ord.OrderID);
}

.NET Framework
Available since 3.5
Return to top
Show: