AddEnumerationPropertyValue Method (String, Int32)
Adds an enumeration value to the current enumerated property with the specified enumeration value and rank.
Namespace: Microsoft.CommerceServer.Catalog
Assembly: Microsoft.CommerceServer.Catalog (in Microsoft.CommerceServer.Catalog.dll)
Syntax
'Declaration
Public Sub AddEnumerationPropertyValue ( _
enumValue As String, _
rank As Integer _
)
'Usage
Dim instance As CatalogEnumerationProperty
Dim enumValue As String
Dim rank As Integer
instance.AddEnumerationPropertyValue(enumValue, _
rank)
public void AddEnumerationPropertyValue(
string enumValue,
int rank
)
public:
void AddEnumerationPropertyValue(
String^ enumValue,
int rank
)
public function AddEnumerationPropertyValue(
enumValue : String,
rank : int
)
Parameters
- enumValue
Type: System..::.String
The enumeration value to add.
- rank
Type: System..::.Int32
The rank of this enumeration value (for sequencing).
Exceptions
Exception | Condition |
---|---|
ValidationException | The enumValue is invalid. |
ArgumentNullException | The enumValue is nullNothingnullptra null reference (Nothing in Visual Basic) |
EntityDoesNotExistException | The property does not exist. |
EntityAlreadyExistsException | The enumValue already exists. |
Remarks
Prioritizing, ordering, or sequencing may involve using the rank Property. Positive and negative rank values are allowed in the catalog system.
You can use this method to add an enumeration value to a property of the Enumeration datatype. If specified, the language should:
Not be null or blank.
Not exceed 10 characters.
Not contain the ,'[] characters.
Be specified for multilingual properties only.
Any new enumeration values added to the property will be saved to the catalog system only when the Save method is called.
Examples
// Create the property
property = (CatalogEnumerationProperty)catalogContext.CreateProperty(propertyName, CatalogDataType.Enumeration, 0);
// Add values for the enumeration property. The language should be specified only if the
// property is language sensitive. You can also assign a rank to each of the enumeration values
int rank = 0;
property.AddEnumerationPropertyValue("Small", rank);
property.AddEnumerationPropertyValue("Big", ++rank);
property.AddEnumerationPropertyValue("Large", ++rank);
property.AddEnumerationPropertyValue("Extra Large", ++rank);
// Call property.Save to Save the changes to the catalog system
property.Save();
// Accessing the enumeration values
foreach (CatalogEnumerationPropertyValuesDataSet.EnumerationPropertyValue enumValue in property.EnumerationValues.EnumerationPropertyValues)
{
Console.WriteLine(enumValue.PropertyName);
Console.WriteLine(enumValue.PropertyValue);
Console.WriteLine(enumValue.Rank);
}
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.
See Also
Reference
CatalogEnumerationProperty Class
CatalogEnumerationProperty Members