Share via


RenameDefinition Method

Renames an existing definition and returns a CatalogDefinition object containing the new definition.

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

Syntax

'Declaration
Public Function RenameDefinition ( _
    oldName As String, _
    newName As String _
) As CatalogDefinition
'Usage
Dim instance As CatalogContext
Dim oldName As String
Dim newName As String
Dim returnValue As CatalogDefinition

returnValue = instance.RenameDefinition(oldName, _
    newName)
public CatalogDefinition RenameDefinition(
    string oldName,
    string newName
)
public:
CatalogDefinition^ RenameDefinition(
    String^ oldName, 
    String^ newName
)
public function RenameDefinition(
    oldName : String, 
    newName : String
) : CatalogDefinition

Parameters

  • oldName
    Type: System..::.String
    The definition to rename. Should not be nullNothingnullptra null reference (Nothing in Visual Basic).
  • newName
    Type: System..::.String
    The new name for the definition. Should not be nullNothingnullptra null reference (Nothing in Visual Basic).

Return Value

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

Exceptions

Exception Condition
ArgumentNullException

The oldName or newName is nullNothingnullptra null reference (Nothing in Visual Basic).

ValidationException

The oldName or newName is an empty string or exceeds 128 characters.

NotAuthorizedException

The caller is not authorized to perform this operation.

EntityDoesNotExistException

The definition specified by oldName does not exist in the catalog system.

EntityAlreadyExistsException

The definition specified by newName already exists in the catalog system.

Remarks

This method renames the definition in the catalog system and in all the catalogs using this definition. You can use the CatalogDefinition object returned by this method to access and modify the information on the renamed 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 rename a category definition, add a property to it and access the properties in the definition.

private void RenameCategoryDefinition(CatalogContext catalogContext, string oldDefinitionName, string newDefinitionName)
{
  CatalogDefinition catalogDefinition = catalogContext.RenameDefinition(oldDefinitionName, newDefinitionName);
  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