Freigeben über


2.1.37 EnumType

An EnumType element is used in CSDL 3.0 to declare an enumeration type. Enumeration types are scalar types.

An enumeration type has a Name attribute, an optional UnderlyingType attribute, an optional IsFlags attribute, and a payload that consists of zero or more declared Member elements.

The following is an example of the EnumType element.

 <EnumType Name="ContentType" UnderlyingType="Edm.Int32" IsFlags="true">
    <Member Name="Liquid" Value="1"/>
    <Member Name="Perishable" Value="2"/>
    <Member Name="Edible" Value="4"/>
 </EnumType>

Enumeration types are equal-comparable, order-comparable, and can participate in entity Key elements—that is, they can be the Key or can be a part of the Key. An enumeration can be categorized as an EDM type.

The following rules apply to the EnumType element:

  • EnumType elements MUST specify a Name attribute that is of type SimpleIdentifier.

  • EnumType is a schema level named element and has a unique name.

  • EnumType elements can specify an UnderlyingType attribute which is an integral EDMSimpleType, such as SByte, Int16, Int32, Int64, or Byte. Edm.Int32 is assumed if it is not specified in the declaration.

  • EnumType elements can specify an IsFlags Boolean attribute, which are assumed to be false if it is not specified in the declaration. If the enumeration type can be treated as a bit field, IsFlags is set to "true".

  • EnumType elements can contain a list of zero or more Member child elements that are referred to as declared enumeration members.

Graphic representation in table format of the rules that apply to the EnumType element.