Udostępnij za pośrednictwem


CreateDefinition Method

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

Creates a catalog definition of the specified CatalogDefinitionType in the catalog system and returns a CatalogDefinition object containing the definition information.

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

Syntax

'Declaration
Public Function CreateDefinition ( _
    definitionName As String, _
    definitionType As CatalogDefinitionType _
) As CatalogDefinition
'Usage
Dim instance As CatalogContext
Dim definitionName As String
Dim definitionType As CatalogDefinitionType
Dim returnValue As CatalogDefinition

returnValue = instance.CreateDefinition(definitionName, _
    definitionType)
public CatalogDefinition CreateDefinition(
    string definitionName,
    CatalogDefinitionType definitionType
)
public:
CatalogDefinition^ CreateDefinition(
    String^ definitionName, 
    CatalogDefinitionType definitionType
)
public function CreateDefinition(
    definitionName : String, 
    definitionType : CatalogDefinitionType
) : CatalogDefinition

Parameters

  • definitionName
    Type: System..::.String
    The name of the definition. Should not be nullNothingnullptra null reference (Nothing in Visual Basic).

Return Value

Type: Microsoft.CommerceServer.Catalog..::.CatalogDefinition
A CatalogDefinition object containing the newly created definition.

Exceptions

Exception Condition
ArgumentNullException

The definitionName is nullNothingnullptra null reference (Nothing in Visual Basic).

ValidationException

The definitionName is an empty string or exceeds 128 characters.

NotAuthorizedException

The caller is not authorized to perform this operation.

EntityAlreadyExistsException

The definitionName already exists in the catalog system.

Remarks

You can use the returned CatalogDefinition object to set information on the definition and add properties to the definition. If you make changes to the CatalogDefinition object you should call the Save method to save the changes to the catalog system.

Examples

This example describes how to create a category definition, add a property to it and access the properties in the definition.

private void CreateCategoryDefinition(CatalogContext catalogContext, string definitionName)
{
  CatalogDefinition catalogDefinition = catalogContext.CreateDefinition(CatalogDefinitionType.CategoryDefinition, definitionName);
  catalogDefinition.AddProperty("PropertyToAdd", DefinitionPropertyType.NormalProperty);
  catalogDefinition.Save();
  foreach(CatalogDefinitionPropertiesDataSet.CatalogDefinitionProperty catalogDefinitionProperty in catalogDefinition.DefinitionProperties.CatalogDefinitionProperties)
  {
    string propertyName = catalogDefinitionProperty.PropertyName;
    int propertyOrder = catalogDefinitionProperty.PropertyOrder;
    DefinitionPropertyType propertyType = (DefinitionPropertyType)catalogDefinitionProperty.PropertyType;
  }
}

Permissions

See Also

Reference

CatalogContext Class

CatalogContext Members

Microsoft.CommerceServer.Catalog Namespace