2.1.7 ComplexType

A ComplexType element represents a set of related information. Like an EntityType element, a ComplexType element consists of one or more properties of scalar type or complex type. However, unlike an EntityType element, a ComplexType element cannot have an entity Key element or any NavigationProperty elements. ComplexType can be categorized as an EDM type.

A ComplexType element provides a mechanism to create declared properties with a rich (structured) payload. Its definition includes its name and payload. The payload of a ComplexType is very similar to that of an EntityType.

The following is an example of the ComplexType element.

   <ComplexType Name="CAddress">
     <Documentation> 
         <Summary>This complextype describes the concept of an Address</Summary> 
         <LongDescription>This complextype describes the concept of an Address for use with Customer and other Entities</LongDescription> 
     </Documentation>
     <Property Name="StreetAddress" Type="String">
         <Documentation> 
             <LongDescription>StreetAddress contains the string describing the address of the street associated with an address</LongDescription> 
         </Documentation>
     </Property>
     <Property Name="City" Type="String" />
     <Property Name="Region" Type="String" />
     <Property Name="PostalCode" Type="String" />
   </ComplexType>

The following rules apply to the ComplexType element:

  • A ComplexType MUST have a Name attribute defined. Name is of type SimpleIdentifier and represents the name of this ComplexType.

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

  • In CSDL 1.1, CSDL 1.2, CSDL 2.0, and CSDL 3.0, a ComplexType can derive from a BaseType. BaseType is either the namespace qualified name or alias qualified name of another ComplexType that is in scope.

  • A ComplexType cannot introduce an inheritance cycle via the BaseType attribute.

  • In CSDL 1.1, CSDL 1.2, CSDL 2.0, and CSDL 3.0, ComplexType can have its Abstract attribute set to "true". By default, Abstract is set to "false".

  • A ComplexType can contain any number of AnnotationAttribute attributes. The full names of the AnnotationAttribute attributes cannot collide.

  • A ComplexType element can contain a maximum of one Documentation element.

  • A ComplexType can have any number of Property elements.

  • In CSDL 1.1, CSDL 1.2, CSDL 2.0, and CSDL 3.0, the property names of a ComplexType MUST be uniquely named within the inheritance hierarchy for the ComplexType. ComplexType properties MUST NOT have the same name as their declaring ComplexType or any of its base types.

  • ComplexType can contain any number of AnnotationElement elements.

  • Child elements of ComplexType are to appear in this sequence: Documentation, Property, AnnotationElement.

  • In CSDL 3.0, ComplexType can contain any number of TypeAnnotation elements.

  • In CSDL 3.0, ComplexType can contain any number of ValueAnnotation elements.

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

All child elements are to appear in the order indicated. For all child elements within a given choice, the child elements can be ordered arbitrarily.

Show: