共用方式為


ModificationFunctionMapping (AssociationSetMapping)

ModificationFunctionMapping 項目在 Entity Data Model (EDM) 中是做為 AssociationSetMapping 項目的子項目,會指定用於插入和刪除實體間 Association 執行個體的預存程序。當儲存模型的連結資料表有支援您要對應的多對多關聯時,請在 AssociationSetMapping 項目中使用 ModificationFunctionMapping 項目。

AssociationSetMappping 函式中 ModificationFunctionMapping 項目所包含的 InsertFunction 項目,可以識別用於建立實體間關聯的預存程序。ModificationFunctionMapping 項目也包含 DeleteFunction 項目,可以識別用於刪除實體間關聯的預存程序。為了要定義關聯中的實體,InsertFunctionDeleteFunction 項目都使用 EndProperty 子項目。

Note附註

ModificationFunctionMapping 項目也可以對應用於插入、更新或刪除 EntityType 項目執行個體的預存程序。在這個情況下,ModificationFunctionMapping 項目是 EntityTypeMapping 項目的子項目,而後者則包含在 EntitySetMapping 項目中。如需詳細資訊,請參閱 ModificationFunctionMapping (EntityTypeMapping)預存程序支援 (Entity Framework)

範例

在這個範例中,ModificationFunctionMapping 項目會使用其 InsertFunctionDeleteFunction 項目,識別用於建立或刪除 Contact 實體和 Address 實體間關聯的預存程序。為了指定 ContactAddress 實體,InsertFunctionDeleteFunction 項目會使用其 EndProperty 項目。這些 EndProperty 項目則會使用其 ScalarProperty 子項目,描述 Association 兩端實體之索引鍵值的參數繫結。ScalarProperty 子項目也會指定預存程序的相對應參數。

Note附註

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>

另請參閱

工作

HOW TO:定義具有預存程序的模型 (Entity Framework)

概念

預存程序支援 (Entity Framework)
InsertFunction (AssociationSetMapping
DeleteFunction (AssociationSetMapping)
EndProperty (AssociationSet ModificationFunctionMapping)