GetInventoryCatalogs Method (String, SearchOptions, Int32)
For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.
Returns an InventoryCatalogCollection object containing the list of the inventory catalogs in the inventory system that match the specified search clause. The total number of records matching the query are available.
Namespace: Microsoft.CommerceServer.Inventory
Assembly: Microsoft.CommerceServer.Catalog (in Microsoft.CommerceServer.Catalog.dll)
Syntax
'Declaration
Public Function GetInventoryCatalogs ( _
searchClause As String, _
searchOptions As SearchOptions, _
<OutAttribute> ByRef totalRecords As Integer _
) As InventoryCatalogCollection
'Usage
Dim instance As InventoryContext
Dim searchClause As String
Dim searchOptions As SearchOptions
Dim totalRecords As Integer
Dim returnValue As InventoryCatalogCollection
returnValue = instance.GetInventoryCatalogs(searchClause, _
searchOptions, totalRecords)
public InventoryCatalogCollection GetInventoryCatalogs(
string searchClause,
SearchOptions searchOptions,
out int totalRecords
)
public:
InventoryCatalogCollection^ GetInventoryCatalogs(
String^ searchClause,
SearchOptions^ searchOptions,
[OutAttribute] int% totalRecords
)
public function GetInventoryCatalogs(
searchClause : String,
searchOptions : SearchOptions,
totalRecords : int
) : InventoryCatalogCollection
Parameters
- searchClause
Type: System..::.String
The criteria, the search clause to filter the inventory catalogs.
- searchOptions
Type: Microsoft.CommerceServer.Catalog..::.SearchOptions
The SearchOptions object. May be nullNothingnullptra null reference (Nothing in Visual Basic).
- totalRecords
Type: System..::.Int32%
Returns the total number of Inventory catalogs that match the searchClause.
Return Value
Type: Microsoft.CommerceServer.Inventory..::.InventoryCatalogCollection
An InventoryCatalogCollection object containing the list of all the inventory catalogs in the inventory system matching the search clause and filtered by 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.
It also returns the total number of inventory catalogs that match the clause specified by the searchClause parameter.
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);
int numInventoryCatalogs;
InventoryCatalogCollection inventoryCatalogs = inventoryContext.GetInventoryCatalogs(searchClause, searchOptions, out numInventoryCatalogs);
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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.