Share via


How to Enumerate Search Results

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

The methods that search the orders database — SearchPurchaseOrders and SearchBaskets — return a DataSet object. The DataSet contains a collection of DataTable objects. Each DataTable object contains a collection of DataRow objects, which in turn contain a collection of DataColumn objects. Each DataRow represents a purchase order or a basket that has met the search criteria that you specified. Each DataColumn contains the value of a property of the purchase order or the basket. To enumerate the results of a search, you loop through the DataRow and DataColumn objects.

Note

The DataSet only contains a DataColumn for the properties of the basket or purchase order that you specify in the search options, plus the OrderGroupId property and the LastModified property. For more information about specifying search options, see How to Specify Search Options.

To enumerate search results

  1. Call SearchPurchaseOrders or SearchBaskets to get a DataSet that contains the search results.

  2. Get the first DataTable in the search results. (The DataSet that the SearchPurchaseOrders and SearchBaskets methods return contains only one DataTable.)

  3. Loop through all DataRow objects in the DataTable.

  4. Read the value of the DataColumn, either directly or by looping through all DataColumn objects in the DataRow.

    The following code example illustrates how to enumerate the result of searching for baskets.

    Note

    For complete code examples that illustrate how to enumerate search results, see Sample Basket Search Implementation and Sample Purchase Order Search Implementation.

    // Perform the search.
    DataSet results = manager.SearchBaskets(clause, options);
    
    // Enumerate the results of the search.
    foreach (DataTable table in results.Tables)
    {
        Console.WriteLine("Table: " + table.TableName);
        foreach (DataRow row in table.Rows)
        {
            Console.WriteLine("  Row");
            foreach (DataColumn column in table.Columns)
            {
                Console.WriteLine("    " + column.ColumnName + ": " +
                    row[column]);
            }
        }
    }
    

See Also

Other Resources

How to Search for Baskets

Sample Basket Search Implementation

Sample Purchase Order Search Implementation

Searching the Orders Database