Dependent 元素 (SSDL)
以存储架构定义语言 (SSDL) 表示的 Dependent 元素是 ReferentialConstraint 元素的子元素,用于定义外键约束(也称为“引用约束”)的依赖端。 Dependent 元素指定表中引用一个(或多个)主键列的一个(或多个)列。 PropertyRef 元素指定所引用的列。 Principal 元素指定由 Dependent 元素中指定的列引用的主键列。
Dependent 元素可以具有以下子元素(按所列顺序):
PropertyRef(一个或多个)
批注元素(零个或多个)
适用的特性
下表介绍可应用于 Dependent 元素的特性。
特性名称 | 是否必需 | 值 |
---|---|---|
Role |
是 |
与相应的 End 元素的 Role 特性(若使用)的值相同的值;否则为包含引用列的表的名称。 |
注意: |
---|
可以将任何数量的批注特性(自定义 XML 特性)应用于 Dependent 元素。然而,自定义特性可能不属于为 CSDL 保留的任何 XML 命名空间。任何两个自定义特性的完全限定名称都不能相同。 |
示例
下面的示例显示一个 Association 元素,该元素使用 ReferentialConstraint 元素指定参与 FK_CustomerOrders 外键约束的列。 Dependent 元素将 Order 表的 CustomerId 列指定为约束的依赖端。
<Association Name="FK_CustomerOrders">
<End Role="Customers"
Type="ExampleModel.Store.Customers" Multiplicity="1">
<OnDelete Action="Cascade" />
</End>
<End Role="Orders"
Type="ExampleModel.Store.Orders" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Customers">
<PropertyRef Name="CustomerId" />
</Principal>
<Dependent Role="Orders">
<PropertyRef Name="CustomerId" />
</Dependent>
</ReferentialConstraint>
</Association>