Compartir a través de


Complex Type (EDM)

The ComplexType in the Entity Data Model (EDM) is a data type with internal structure but without a Key property. The ComplexType is used to implement a property that has internal properties of its own.

Either an EntityType or a ComplexType can have a property declared as ComplexType. This property must be mapped as a complex property in the mapping specification.

The Address property of the following CCustomer entity is implemented as ComplexType.

<EntityType Name="CCustomer">
  <Key>
    <PropertyRef Name="CustomerId" />
  </Key>
  <Property Name="CustomerId" Type="Int32" Nullable="false" />
  <Property Name="CompanyName" Type="String" />
  <Property Name="ContactName" Type="String" />
  <Property Name="ContactTitle" Type="String" />
  <Property Name="Address" Type="Self.CAddress" Nullable="false" />
</EntityType>

<ComplexType Name="CAddress">
  <Property Name="StreetAddress" Type="String" />
  <Property Name="City" Type="String" />
  <Property Name="Region" Type="String" />
  <Property Name="PostalCode" Type="String" />
  <Property Name="Country" Type="String" />
  <Property Name="Phone" Type="String" />
  <Property Name="Fax" Type="String" />
</ComplexType>

See Also

Tasks

How to: Define a Model with Complex Type (Entity Framework)
How to: Create and Execute Object Queries with Complex Types (Entity Framework)

Concepts

Mapping Complex Type to Stored Procedures (Entity Framework)