Share via


附註屬性 (SSDL)

存放結構定義語言 (SSDL) 中的 Annotation 屬性是儲存體模型中的自訂 XML 屬性,它們可提供與儲存體模型中之項目相關的額外中繼資料。 除了擁有有效的 XML 結構外,下列條件約束適用於 Annotation 屬性:

  • Annotation 屬性不能在任何 XML 命名空間之中,這是保留供 SSDL 之用。

  • 任兩個 Annotation 屬性的完整名稱不能相同。

可以將一個以上的 Annotation 屬性套用至指定的 SSDL 項目。 經由使用 System.Data.Metadata.Edm 命名空間中的類別,即可在執行階段存取包含在 annotation 項目中的中繼資料。

範例

下列範例顯示的 EntityType 項目,擁有已套用至 OrderId 屬性的 annotation 屬性。 該範例也顯示已加入至 EntityType 項目的 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>

另請參閱

概念

Annotation 項目 (SSDL)
SSDL 規格

其他資源

CSDL、SSDL 和 MSL 規格