ModificationFunctionMapping (AssociationSetMapping)
作为实体数据模型 (EDM) 中 AssociationSetMapping 元素的子元素,ModificationFunctionMapping 元素指定插入和删除实体之间的 Association 实例的存储过程。当要映射存储模型中的链接表所支持的多对多关联时,使用 AssociationSetMapping 元素中的 ModificationFunctionMapping 元素。
在 AssociationSetMappping 函数中,ModificationFunctionMapping 元素包含一个 InsertFunction 元素,该元素标识创建实体之间的关联的存储过程。ModificationFunctionMapping 元素还包含一个 DeleteFunction 元素,该元素标识删除实体之间的关联的存储过程。为了定义关联中的实体,InsertFunction 和 DeleteFunction 元素都使用了 EndProperty 子元素。
注意 |
---|
ModificationFunctionMapping 元素还可映射插入、更新或删除 EntityType 元素实例的存储过程。在这种情况下,ModificationFunctionMapping 元素是 EntityTypeMapping 元素(该元素包含在 EntitySetMapping 元素中)的子元素。有关更多信息,请参见 ModificationFunctionMapping (EntityTypeMapping) 和存储过程支持(实体框架)。 |
示例
在此示例中,ModificationFunctionMapping 元素使用其 InsertFunction 和 DeleteFunction 元素标识创建或删除 Contact
实体与 Address
实体之间的关联的存储过程。为了指定 Contact
和 Address
实体,InsertFunction 和 DeleteFunction 元素使用各自的 EndProperty 元素。这些 EndProperty 元素使用其 ScalarProperty 子元素来描述 Association 各端实体的键值的参数绑定。此外,ScalarProperty 子元素还指定存储过程的相应参数。
注意 |
---|
在 AssociationSet 存储过程映射中所声明的 EndProperty 绑定与在 EntitySet 函数映射中所声明的 AssociationEnd 元素类似。但对于 EndProperty 元素,包含这些元素的 AssociationSet 元素提供了必要的上下文。 |
下面的示例演示一个包含 ModificationFunctionMapping 元素的完整 AssociationSetMapping 元素:
<AssociationSetMapping Name="Contact_Address"
TypeName="ContactInformationModel.Contact_Address"
StoreEntitySet="Contact_Address">
<EndProperty Name="Address">
<ScalarProperty Name="AddressID" ColumnName="AddressID" />
</EndProperty>
<EndProperty Name="Contact">
<ScalarProperty Name="ContactID" ColumnName="ContactID" />
</EndProperty>
<ModificationFunctionMapping>
<DeleteFunction
FunctionName="ContactInformationModel.Store.DeleteAddress">
<EndProperty Name="Address">
<ScalarProperty Name="AddressID" ParameterName="AddressID"/>
</EndProperty>
<EndProperty Name="Contact">
<ScalarProperty Name="ContactID" ParameterName="ContactID"/>
</EndProperty>
</DeleteFunction>
<InsertFunction
FunctionName="ContactInformationModel.Store.SetAddress">
<EndProperty Name="Address">
<ScalarProperty Name="AddressID" ParameterName="AddressID"/>
</EndProperty>
<EndProperty Name="Contact">
<ScalarProperty Name="ContactID" ParameterName="ContactID"/>
</EndProperty>
</InsertFunction>
</ModificationFunctionMapping>
另请参见
任务
概念
存储过程支持(实体框架)
InsertFunction (AssociationSetMapping)
DeleteFunction (AssociationSetMapping)
EndProperty (AssociationSet ModificationFunctionMapping)