Поделиться через


Function Element (SSDL)

The Function element definition in store schema definition language (SSDL) in the Entity Data Model (EDM) specifies that a stored procedure exists in the database. Nested parameter elements specify the names of parameters and their data types. These definitions identify a stored procedure that can be mapped to an entity and its properties.

In the current release of the Entity Framework the IsComposable attribute of a function declaration representing a stored procedure must be set to false. This setting indicates that results returned by the procedure cannot be used in the FROM clause of other SQL statements.

For a how-to topic on stored procedures, see How to: Define a Model with a Stored Procedure (Entity Framework).

The following example shows the SSDL metadata for the SUBSTRING function.

<?xml version="1.0" encoding="utf-8"?>
<Schema Namespace="Northwind" Alias="Self" 
xmlns:edm="https://schemas.microsoft.com/ado/2006/04/edm/ssdl"
   xmlns="https://schemas.microsoft.com/ado/2006/04/edm/ssdl">

   <! Other declarations.-->
  <Function Name="SUBSTRING" ReturnType="varchar" BuiltIn="true">
    <Documentation> 
       <Summary>Function accepts a source string, the starting position
         and the length of the sub-string to be extracted</Summary> 
       <LongDescription>Long Description if needed. </LongDescription> 
    </Documentation>

    <Parameter Name="str" Mode="In" Type="varchar" />
    <Parameter Name="start" Mode="In" Type="int">
      <Documentation> 
        <Summary>The starting position of the substring</Summary> 
        <LongDescription>Long Description.</LongDescription> 
      </Documentation>
    </Parameter>

    <Parameter Name="length" Mode="In" Type="int" />
  </Function>

</Schema>

The following SSDL declarations specify three stored procedures used to create, update, and delete entities and the data they contain: CreateVendor, UpdateVendor, and DeleteVendor.

<Function Name="CreateVendor" IsComposable="false" Schema="dbo">    
    <Parameter Name="ID" Type="int" />    
    <Parameter Name="Name" Type="nvarchar" />    
    <Parameter Name="Description" Type="nvarchar(max)" />    
  </Function>

  <Function Name="UpdateVendor" IsComposable="false" Schema="dbo">
    <Parameter Name="ID" Type="int" />
    <Parameter Name="Name" Type="nvarchar" />
    <Parameter Name="Description" Type="nvarchar(max)" />
  </Function>

  <Function Name="DeleteVendor" IsComposable="false" Schema="dbo">
    <Parameter Name="ID" Type="int" />    
  </Function>
</Schema>

See Also

Tasks

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

Concepts

Stored Procedure Support (Entity Framework)