ComplexProperty 要素 (MSL)
マッピング仕様言語 (MSL) の ComplexProperty 要素は、概念モデル エンティティ型の複合型プロパティと、基になるデータベースのテーブル列との間のマッピングを定義します。 プロパティ列のマッピングは、子 ScalarProperty 要素で指定されます。
ComplexType プロパティ要素には、次の子要素を含めることができます。
ScalarProperty (0 個以上)
ComplexProperty (0 個以上)
ComplextTypeMapping (0 個以上)
Condition (0 個以上)
適用可能な属性
The following table describes the attributes that are applicable to the ComplexProperty element:
属性名 | 必須 | Value |
---|---|---|
Name |
有効 |
マップされる概念モデルのエンティティ型の複合プロパティ名。 |
TypeName |
いいえ |
概念モデルのプロパティ型の名前空間修飾名。 |
例
The following example is based on the School 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>
Person エンティティ型の LastName プロパティと FirstName プロパティは、1 つの複合プロパティ、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>
次の MSL は、Name プロパティを、基になるデータベースの列にマップするために使用される ComplexProperty 要素を示しています。
<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>