Udostępnij za pośrednictwem


UpdateFunction (EntityTypeMapping)

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

To update an entity, the UpdateFunction element maps the properties of an entity in the storage schema to parameters of a stored procedure in the database. The stored procedure modifies instances of the data type in storage.

Example

In the following example, the UpdateFunction element maps a stored procedure that modifies instances of the SalesOrderDetail entity in the Adventureworks sales model. Each ScalarProperty child element of the UpdateFunction element maps a property of the SalesOrderDetail entity in the storage model 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.

  • The ParameterName attribute identifies the stored-procedure parameter to which the property of the 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 UpdateFunction element includes an AssociationEnd element that maps associations that the entity being modified may reference. For more information, see AssociationEnd (EntityTypeMapping).

  <UpdateFunction
     FunctionName="AdventureWorksModel.Store.UpdateSalesOrderDetail" >
        <ScalarProperty Name="OrderQty" ParameterName="OrderQty"  Version="Current"/>
        <ScalarProperty Name="SalesOrderDetailID"
           ParameterName="SalesOrderDetailID" Version="Current"/>
      <AssociationEnd
         AssociationSet="FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID"
    From="SalesOrderDetail" To="SalesOrderHeader">
        <ScalarProperty Name="SalesOrderID"
          ParameterName="SalesOrderID" Version="Current" />
       </AssociationEnd>
  </UpdateFunction>

See Also

Tasks

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

Concepts

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