次の方法で共有


annotation 要素 (SSDL)

ストア スキーマ定義言語 (SSDL) の annotation 要素は、ストレージ モデルに関する追加のメタデータを指定するストレージ モデルのカスタム XML 要素です。有効な XML 構造が必要であることに加え、annotation 要素には次の制約が適用されます。

  • annotation 要素は、SSDL 用に予約された XML 名前空間内に存在できません。

  • 2 つの annotation 要素の完全修飾名を同じにすることはできません。

  • annotation 要素は、特定の SSDL 要素のその他すべての子要素より後に指定する必要があります。

複数の annotation 要素を特定の SSDL 要素の子にすることができます。.NET Framework Version 4 以降では、annotation 要素に含まれるメタデータに、System.Data.Metadata.Edm 名前空間内のクラスを使用して実行時にアクセスできます。

次の例は、annotation 要素 (CustomElement) を持つ EntityType 要素を示しています。また、この例では OrderId プロパティに適用される annotation 属性も示しています。

<EntityType Name="Orders" xmlns:c="http://CustomNamespace">
  <Key>
    <PropertyRef Name="OrderId" />
  </Key>
  <Property Name="OrderId" Type="int" Nullable="false" 
            c:CustomAttribute="someValue"/>
  <Property Name="ProductId" Type="int" Nullable="false" />
  <Property Name="Quantity" Type="int" Nullable="false" />
  <Property Name="CustomerId" Type="int" Nullable="false" />
  <c:CustomElement>
    Custom data here.
  </c:CustomElement>
</EntityType>
<EntityType Name="Orders" xmlns:c="http://CustomNamespace">
  <Key>
    <PropertyRef Name="OrderId" />
  </Key>
  <Property Name="OrderId" Type="int" Nullable="false" c:CustomAttribute="someValue" />
  <Property Name="ProductId" Type="int" Nullable="false" />
  <Property Name="Quantity" Type="int" Nullable="false" />
  <Property Name="CustomerId" Type="int" Nullable="false" />
  <c:CustomElement>
          Custom data here.
        </c:CustomElement>
</EntityType>

<EntityType Name="Orders" xmlns:c="http://CustomNamespace">
  <Key>
    <PropertyRef Name="OrderId" />
  </Key>
  <Property Name="OrderId" Type="int" Nullable="false" c:CustomAttribute="someValue" />
  <Property Name="ProductId" Type="int" Nullable="false" />
  <Property Name="Quantity" Type="int" Nullable="false" />
  <Property Name="CustomerId" Type="int" Nullable="false" />
  <c:CustomElement>
          Custom data here.
        </c:CustomElement>
</EntityType>

関連項目

概念

annotation 属性

SSDL 仕様

その他の技術情報

CSDL、SSDL、および MSL 仕様