批注特性 (SSDL)
以存储架构定义语言 (SSDL) 表示的批注特性在存储模型中是自定义 XML 特性,这些特性提供有关存储模型中元素的额外元数据。 除了具有有效的 XML 结构之外,以下约束也适用于批注特性:
批注特性不能位于为 SSDL 保留的任何 XML 命名空间中。
任何两个批注特性的完全限定名称都不能相同。
可以将多个批注特性应用于一个给定的 SSDL 元素。 可以在运行时通过使用 System.Data.Metadata.Edm 命名空间中的类访问批注元素中包含的元数据。
示例
下面的示例演示一个 EntityType 元素,该元素已将批注特性应用于 OrderId 属性。 本示例还演示了一个添加到 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>