IMultipleResults.GetResult<TElement> Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Haalt het volgende resultaat op als een reeks van een opgegeven type.
public:
generic <typename TElement>
System::Collections::Generic::IEnumerable<TElement> ^ GetResult();
public System.Collections.Generic.IEnumerable<TElement> GetResult<TElement>();
abstract member GetResult : unit -> seq<'Element>
Public Function GetResult(Of TElement) () As IEnumerable(Of TElement)
Type parameters
- TElement
Het type van de reeks dat moet worden geretourneerd.
Retouren
Een opsomming voor het herhalen van de resultaten.
Voorbeelden
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);
}
Dim db As New Northwnd("c:\northwnd.mdf")
' Assign the results of the procedure with an argument
' of (1) to local variable 'result'.
Dim result As IMultipleResults = db.VariableResultShapes(1)
' Iterate through the list and write results (the company name)
' to the console.
For Each compName As VariableResultShapesResult1 _
In result.GetResult(Of VariableResultShapesResult1)()
Console.WriteLine(compName.CompanyName)
Next
' 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.'
Dim result2 As IMultipleResults = db.VariableResultShapes(2)
' Iterate through the list and write results (the order IDs)
' to the console.
For Each ord As VariableResultShapesResult2 _
In result2.GetResult(Of VariableResultShapesResult2)()
Console.WriteLine(ord.OrderID)
Next
Opmerkingen
U gebruikt code die vergelijkbaar is met de volgende code om deze opgeslagen procedure uit te voeren.
Opmerking
U moet het GetResult patroon gebruiken om een opsomming te verkrijgen van het juiste type, op basis van uw kennis van de opgeslagen procedure.