ComplexProperty Element (MSL)

A ComplexProperty element in mapping specification language (MSL) defines the mapping between a complex type property on a conceptual model entity type and table columns in the underlying database. The property-column mappings are specified in child ScalarProperty elements.

The ComplexType property element can have the following child elements:

Applicable Attributes

The following table describes the attributes that are applicable to the ComplexProperty element:

Attribute Name Is Required Value

Name

Yes

The name of the complex property of an entity type in the conceptual model that is being mapped.

TypeName

No

The namespace-qualified name of the conceptual model property type.

Example

The following example is based on the School model. The following complex type has been added to the conceptual model:

<ComplexType Name="FullName">
  <Property Type="String" Name="LastName" 
            Nullable="false" MaxLength="50" 
            FixedLength="false" Unicode="true" />
  <Property Type="String" Name="FirstName" 
            Nullable="false" MaxLength="50" 
            FixedLength="false" Unicode="true" />
</ComplexType>

The LastName and FirstName properties of the Person entity type have been replaced with one complex property, Name:

<EntityType Name="Person">
  <Key>
    <PropertyRef Name="PersonID" />
  </Key>
  <Property Name="PersonID" Type="Int32" Nullable="false" 
            annotation:StoreGeneratedPattern="Identity" />
  <Property Name="HireDate" Type="DateTime" />
  <Property Name="EnrollmentDate" Type="DateTime" />
  <Property Name="Name" Type="SchoolModel.FullName" Nullable="false" />
</EntityType>

The following MSL shows the ComplexProperty element used to map the Name property to columns in the underlying database:

<EntitySetMapping Name="People">
  <EntityTypeMapping TypeName="SchoolModel.Person">
    <MappingFragment StoreEntitySet="Person">
      <ScalarProperty Name="PersonID" ColumnName="PersonID" />
      <ScalarProperty Name="HireDate" ColumnName="HireDate" />
      <ScalarProperty Name="EnrollmentDate" ColumnName="EnrollmentDate" />
      <ComplexProperty Name="Name" TypeName="SchoolModel.FullName">
        <ScalarProperty Name="FirstName" ColumnName="FirstName" />
        <ScalarProperty Name="LastName" ColumnName="LastName" />  
      </ComplexProperty>
    </MappingFragment>
  </EntityTypeMapping>
</EntitySetMapping>

See Also

Other Resources

CSDL, SSDL, and MSL Specifications
Modeling and Mapping