Share via


How to Specify Search Options

Search options specify how search results should be returned. When you search the orders database for baskets or purchase orders, you can specify:

  • Which properties (columns of the database) to return for each record that is retrieved.

  • How many records to retrieve, and at which record to start.

  • How to sort the records that are retrieved.

To specify search options

  1. Create a SearchOptions object.

  2. Set the object properties in which you are interested.

    Note

    There are SearchOptions classes in both the Microsoft.CommerceServer namespace and the Microsoft.CommerceServer.Catalog namespace. Be sure to use the SearchOptions class in the Microsoft.CommerceServer namespace when you work with the Orders System data management classes. Only properties of the top-level class (the Basket class or the PurchaseOrder class) can be returned. Even if your search clause references properties of nested classes, properties of the nested class cannot be returned.

    The following code example illustrates how to specify search options.

    Note

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

    SearchOptions options = new SearchOptions();
    options.PropertiesToReturn = "LastModified, Created";
    options.SortProperties = "Created";
    options.NumberOfRecordsToReturn = 500;
    

See Also

Reference

SearchOptions

Other Resources

Sample Basket Search Implementation

Sample Purchase Order Search Implementation

Searching the Orders Database