批注元素 (SSDL)

以存储架构定义语言 (SSDL) 表示的批注元素是存储模型中的自定义 XML 元素,可提供有关存储模型的额外元数据。 除了具有有效的 XML 结构之外,批注元素还应满足以下约束:

  • 批注元素不能位于为 SSDL 保留的任何 XML 命名空间中。

  • 任何两个批注元素的完全限定名称都不能相同。

  • 批注元素必须出现在给定 SSDL 元素的所有其他子元素之后。

多个批注元素可能是某个给定 SSDL 元素的子元素。 从 .NET Framework 版本 4 开始,可以在运行时通过使用 System.Data.Metadata.Edm 命名空间中的类访问批注元素中包含的元数据。

示例

下面的示例演示一个具有一个批注元素 (CustomElement) 的 EntityType 元素。 该示例还演示了应用于 OrderId 属性的批注特性

<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>

另请参见

概念

批注特性 (SSDL)
SSDL 规范

其他资源

CSDL、SSDL 和 MSL 规范