Function 項目 (SSDL)

Entity Data Model (EDM) 中存放結構定義語言 (SSDL) 內的 Function 項目定義會指定資料庫中有預存程序存在。巢狀參數項目會指定參數的名稱以及參數的資料型別。這些定義會識別可對應至實體和實體之屬性的預存程序。

在目前的 Entity Framework 版本中,代表預存程序之函式宣告的 IsComposable 屬性必須設定為 false。這個設定表示,此程序傳回的結果不能在其他 SQL 陳述式的 FROM 子句中使用。

如需預存程序的作法主題,請參閱 HOW TO:定義具有預存程序的模型 (Entity Framework)

下列範例示範 SUBSTRING 函式的 SSDL 中繼資料。

<?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>

下列 SSDL 宣告會指定三個用來建立、更新及刪除實體與實體所包含之資料的預存程序:CreateVendorUpdateVendorDeleteVendor

<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>

另請參閱

工作

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

概念

預存程序支援 (Entity Framework)