Entity Data Model (EDM) のストア スキーマ定義言語 (SSDL) の Function 要素定義では、ストアド プロシージャがデータベースに存在することを指定します。入れ子になったパラメータ要素では、パラメータの名前とデータ型を指定します。これらの定義により、エンティティおよびそのプロパティにマップできるストアド プロシージャが識別されます。
Entity Framework の現在のリリースでは、ストアド プロシージャを表す関数宣言の IsComposable 属性は、false に設定する必要があります。この設定は、プロシージャから返される結果を他の SQL ステートメントの FROM 句で使用できないということを示します。
ストアド プロシージャの使用方法については、「ストアド プロシージャを使用してモデルを定義する方法 (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 宣言は、エンティティおよびそのデータの作成、更新、および削除を行う 3 つのストアド プロシージャ (CreateVendor、UpdateVendor、および 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>
参照
処理手順
ストアド プロシージャを使用してモデルを定義する方法 (Entity Framework)