Share via


GetInventoryCatalogs Method (String, SearchOptions)

Returns an InventoryCatalogCollection object containing the list of the inventory catalogs in the inventory system that match the specified search clause.

Namespace:  Microsoft.CommerceServer.Inventory
Assembly:  Microsoft.CommerceServer.Catalog (in Microsoft.CommerceServer.Catalog.dll)

Syntax

'Declaration
Public Function GetInventoryCatalogs ( _
    searchClause As String, _
    searchOptions As SearchOptions _
) As InventoryCatalogCollection
'Usage
Dim instance As InventoryContext
Dim searchClause As String
Dim searchOptions As SearchOptions
Dim returnValue As InventoryCatalogCollection

returnValue = instance.GetInventoryCatalogs(searchClause, _
    searchOptions)
public InventoryCatalogCollection GetInventoryCatalogs(
    string searchClause,
    SearchOptions searchOptions
)
public:
InventoryCatalogCollection^ GetInventoryCatalogs(
    String^ searchClause, 
    SearchOptions^ searchOptions
)
public function GetInventoryCatalogs(
    searchClause : String, 
    searchOptions : SearchOptions
) : InventoryCatalogCollection

Parameters

  • searchClause
    Type: System..::.String
    The criteria, the search clause to filter the inventory catalogs.

Return Value

Type: Microsoft.CommerceServer.Inventory..::.InventoryCatalogCollection
An InventoryCatalogCollection object containing the list of all the inventory catalogs in the inventory system matching the specified search clause. The results are filtered as per the searchOptions.

Remarks

You can iterate through the InventoryCatalogCollection and access the properties of the individual inventory catalogs using the InventoryCatalog object. You can set the searchClause to a valid T-SQL where clause which can be used to perform searches on the inventory catalogs. All the properties in the searchClause should be enclosed in []. Any string values in the searchClause should be prefixed with N to allow searching for unicode content. You can use valid T-SQL operators like AND, OR, NOT, LIKE etc in the search condition. For example string searchClause = @"(\[InventoryCatalogName\] like N'IC00%' OR \[InventoryCatalogDescription\] like N'IC00%') AND \[LastModified\]\> '1/1/2000' "; You cannot have the following in the searchClause :

  • The ( and ) should be symmetric. For eg string searchClause = @"([InventoryCatalogName] like N'IC00%' is invalid since the ( is not closed.

  • It should not contain sql comment characters /* and -- unless these characters are enclosed by [].

You can use the searchOptions parameter to specify additional filtering criteria like properties to return, properties to sort on, the starting record and the number of records to return.

Examples

This example demonstrates how to get the inventory catalogs and access the properties of the individual inventory catalogs.

public void GetInventoryCatalogs()
{
  try
  {
    string searchClause = @"([InventoryCatalogName] like N'IC000%' OR [InventoryCatalogDescription] like N'IC000%') AND [LastModified] > '1/1/2000'";
    Microsoft.CommerceServer.Catalog.SearchOptions searchOptions = new Microsoft.CommerceServer.Catalog.SearchOptions();
    searchOptions.PropertiesToReturn = string.Format("{0},{1}", InventoryCatalogsDataSetSchema.InventoryCatalogName, InventoryCatalogsDataSetSchema.InventoryCatalogDescription);
    searchOptions.StartingRecord = 10;
    searchOptions.RecordsToRetrieve = 10;     searchOptions.SortProperty = string.Format("{0},{1}DESC", InventoryCatalogsDataSetSchema.InventoryCatalogName, InventoryCatalogsDataSetSchema.LastModified);
    InventoryCatalogCollection inventoryCatalogs = inventoryContext.GetInventoryCatalogs(searchClause, searchOptions);     int numInventoryCatalogs = inventoryCatalogs.Count;
    foreach(InventoryCatalog inventoryCatalog in inventoryCatalogs)
    {
      Console.WriteLine(inventoryCatalog.Name);
      Console.WriteLine(inventoryCatalog.Description);
      // Accessing associated product catalogs
      foreach(string productCatalog in inventoryCatalog.AssociatedProductCatalogs)
      {
        Console.WriteLine(productCatalog);
      }
    }
     // Accessing the InventoryCatalogs dataset
     foreach(InventoryCatalogsDataSet.InventoryCatalog inventoryCatalog in inventoryCatalogs.DataSet.InventoryCatalogs)
    {
      Console.WriteLine(inventoryCatalog.InventoryCatalogName);
      Console.WriteLine(inventoryCatalog.InventoryCatalogDescription);
      InventoryCatalog inventoryCatalogObject = inventoryContext.GetInventoryCatalog(inventoryCatalog.InventoryCatalogName);
      // Accessing associated product catalogs
      foreach (string productCatalog in inventoryCatalogObject.AssociatedProductCatalogs)
      {
        Console.WriteLine(productCatalog);
      }
    }
  }
  catch (ValidationException ex)
  {
    Console.WriteLine(ex.Message);
  }
  catch (CatalogDatabaseException ex)
  {
    Console.WriteLine(ex.Message);
  }
}

Permissions

See Also

Reference

InventoryContext Class

InventoryContext Members

GetInventoryCatalogs Overload

Microsoft.CommerceServer.Inventory Namespace