Process Multi-Query Results |
Scroll |
The code sample below illustrates various ways to process and iterate an already existing TheMultiQueryResult. Please see "Simple Query" and/or "Query in One Category" for more information on specifying and executing queries.
Visual Basic Imports Therefore.API '...
Public Shared Sub ProcessMultiQueryResult( _ ByVal multiResult As TheMultiQueryResult _ )
' Iterate through search results using nested for-loops Dim i As Integer For i = 0 To multiResult.Count - 1 Step i + 1 Dim j As Integer For j = 0 To multiResult(i).Count - 1 Step j + 1 Dim k As Integer For k = 0 To multiResult(i)(j).Count - 1 Step k + 1 ' Access the k-th field in the j-th row of the i-th query If Not multiResult(i)(j)(k) Is Nothing Then Console.WriteLine(multiResult(i)(j)(k).ToString()) End If Next Next Next
' Iterate through search results using the nested for-each constructs Dim QueryResult As TheQueryResult For Each QueryResult In multiResult Dim row As TheQueryResultRow For Each row In QueryResult Dim obj As Object For Each obj In row If TypeOf obj Is DBNull Then Console.WriteLine("null") Else Console.WriteLine(obj.ToString()) End If Next Next Next
End Sub
C# using Therefore.API; //...
public static void ProcessMultiQueryResult ( TheMultiQueryResult multiResult ) { // Iterate through search results using nested for-loops for (int i = 0; i < multiResult.Count; i++) { for (int j = 0; j < multiResult[i].Count; j++) { for (int k = 0; k < multiResult[i][j].Count; k++) { // Access the k-th field in the j-th row of the i-th query if (multiResult[i][j][k] != null) Console.WriteLine(multiResult[i][j][k].ToString()); } } }
// Iterate through search results using the nested for-each constructs foreach (TheQueryResult QueryResult in multiResult) { foreach (TheQueryResultRow row in QueryResult) { foreach (object obj in row) { if (obj is DBNull) Console.WriteLine("null"); else Console.WriteLine(obj.ToString()); } } } } }
|