共用方式為


DeleteFunction (EntityTypeMapping)

As a child element of an EntityTypeMapping element in the Entity Data Model (EDM), the DeleteFunction element in a ModificationFunctionMapping element identifies the stored procedure that deletes an existing entity.

The DeleteFunction element maps the properties of an entity in the storage schema to the parameters of a stored procedure in the database. The stored procedure deletes instances of the data type in storage.

Example

In the following example, the DeleteFunction element maps a stored procedure that deletes instances of the SalesOrderDetail entity in the Adventureworks sales model. Each ScalarProperty child element in the DeleteFunction element maps a property of the SalesOrderDetail entity to a parameter in the stored-procedure. To map these entities, the ScalarProperty child element uses these attributes:

  • The Name attribute identifies the property of the SalesOrderDetail entity to be mapped.l

  • The ParameterName attribute identifies the stored-procedure parameter to which the property of a SalesOrderDetail entity maps

  • The Version attribute specifies data as either original data read from the database, or current data that has possibly been changed by client code.

In addition to the ScalarProperty child element, the DeleteFunction element includes an AssociationEnd element that maps associations that the entity being created may instantiate. For more information, see AssociationEnd (EntityTypeMapping).

  <DeleteFunction
      FunctionName="AdventureWorksModel.Store.DeleteSalesOrderDetail" >
        <ScalarProperty Name="SalesOrderDetailID"
          ParameterName="SalesOrderDetailID" Version="Original"/>
    <AssociationEnd
      AssociationSet="FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID"
         From="SalesOrderDetail" To="SalesOrderHeader">
          <ScalarProperty Name="SalesOrderID"
            ParameterName="SalesOrderID" />
    </AssociationEnd>
  </DeleteFunction>

See Also

Tasks

How to: Define a Model with a Stored Procedure (Entity Framework)

Concepts

Stored Procedure Support (Entity Framework)
ModificationFunctionMapping (AssociationSetMapping)
UpdateFunction (EntityTypeMapping)
InsertFunction (EntityTypeMapping)