複雜類型 (EDM)
Entity Data Model (EDM) 中的 ComplexType 是含有內部結構但不含 Key 屬性的資料型別。ComplexType 可用來實作本身具有內部屬性的屬性。
EntityType 或 ComplexType 可以有宣告為 ComplexType 的屬性。這個屬性必須在對應規格中對應成複雜屬性。
下列 CCustomer
實體的 Address
屬性是以 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>
另請參閱
工作
HOW TO:定義具有複雜類型的模型 (Entity Framework)
HOW TO:使用複雜類型來建立和執行物件查詢 (Entity Framework)