InsertFunction 要素 (MSL)

マッピング スキーマ言語 (MSL) の InsertFunction 要素は、概念モデル内のエンティティ型またはアソシエーションの挿入関数を、基になるデータベースのストアド プロシージャにマップします。 変更関数のマップ先であるストアド プロシージャは、ストレージ モデル内で宣言する必要があります。 詳細については、「Function 要素 (SSDL)」を参照してください。

Cc716749.note(ja-jp,VS.100).gif注 :
エンティティ型の挿入、更新、および削除の 3 つの操作をすべてストアド プロシージャにマップしないと、マップされていない操作は実行時に失敗して UpdateException がスローされます。

InsertFunction 要素は、ModificationFunctionMapping 要素の子にすることができます。また、EntityTypeMapping 要素または AssociationSetMapping 要素に適用できます。

EntityTypeMapping への InsertFunction の適用

InsertFunction 要素は、EntityTypeMapping 要素に適用されると、概念モデル内のエンティティ型の挿入関数をストアド プロシージャにマップします。

The InsertFunction element can have the following child elements when applied to an EntityTypeMapping element:

適用可能な属性

次の表は、EntityTypeMapping 要素に適用する場合に InsertFunction 要素に適用できる属性を示しています。

属性名 必須 Value

FunctionName

有効

挿入関数のマップ先であるストアド プロシージャの名前空間修飾名。 ストアド プロシージャはストレージ モデル内で宣言する必要があります。

RowsAffectedParameter

いいえ

影響を受ける行の数を返す出力パラメーターの名前。

次の例は、School モデルに基づいており、Person エンティティ型の挿入関数を InsertPerson ストアド プロシージャにマップするために使用される InsertFunction 要素を示しています。 The InsertPerson stored procedure is declared in the storage model.

<EntityTypeMapping TypeName="SchoolModel.Person">
  <ModificationFunctionMapping>
    <InsertFunction FunctionName="SchoolModel.Store.InsertPerson">
      <ScalarProperty Name="EnrollmentDate"
                      ParameterName="EnrollmentDate" />
      <ScalarProperty Name="HireDate" ParameterName="HireDate" />
      <ScalarProperty Name="FirstName" ParameterName="FirstName" />
      <ScalarProperty Name="LastName" ParameterName="LastName" />
      <ResultBinding Name="PersonID" ColumnName="NewPersonID" />
    </InsertFunction>
    <UpdateFunction FunctionName="SchoolModel.Store.UpdatePerson">
      <ScalarProperty Name="EnrollmentDate"
                      ParameterName="EnrollmentDate"
                      Version="Current" />
      <ScalarProperty Name="HireDate" ParameterName="HireDate"
                      Version="Current" />
      <ScalarProperty Name="FirstName" ParameterName="FirstName"
                      Version="Current" />
      <ScalarProperty Name="LastName" ParameterName="LastName"
                      Version="Current" />
      <ScalarProperty Name="PersonID" ParameterName="PersonID"
                      Version="Current" />
    </UpdateFunction>
    <DeleteFunction FunctionName="SchoolModel.Store.DeletePerson">
      <ScalarProperty Name="PersonID" ParameterName="PersonID" />
    </DeleteFunction>
  </ModificationFunctionMapping>
</EntityTypeMapping>

AssociationSetMapping への InsertFunction の適用

InsertFunction 要素は、AssociationSetMapping 要素に適用されると、概念モデル内のアソシエーションの挿入関数をストアド プロシージャにマップします。

The InsertFunction element can have the following child elements when applied to the AssociationSetMapping element:

適用可能な属性

The following table describes the attributes that can be applied to the InsertFunction element when it is applied to the AssociationSetMapping element.

属性名 必須 Value

FunctionName

有効

挿入関数のマップ先であるストアド プロシージャの名前空間修飾名。 ストアド プロシージャはストレージ モデル内で宣言する必要があります。

RowsAffectedParameter

いいえ

影響を受ける行の数を返す出力パラメーターの名前。

次の例は、School モデルに基づいており、CourseInstructor アソシエーションの挿入関数を InsertCourseInstructor ストアド プロシージャにマップするために使用される InsertFunction 要素を示しています。 The InsertCourseInstructor stored procedure is declared in the storage model.

<AssociationSetMapping Name="CourseInstructor" 
                       TypeName="SchoolModel.CourseInstructor" 
                       StoreEntitySet="CourseInstructor">
  <EndProperty Name="Person">
    <ScalarProperty Name="PersonID" ColumnName="PersonID" />
  </EndProperty>
  <EndProperty Name="Course">
    <ScalarProperty Name="CourseID" ColumnName="CourseID" />
  </EndProperty>
  <ModificationFunctionMapping>
    <InsertFunction FunctionName="SchoolModel.Store.InsertCourseInstructor" >   
      <EndProperty Name="Course">
        <ScalarProperty Name="CourseID" ParameterName="courseId"/>
      </EndProperty>
      <EndProperty Name="Person">
        <ScalarProperty Name="PersonID" ParameterName="instructorId"/>
      </EndProperty>
    </InsertFunction>
    <DeleteFunction FunctionName="SchoolModel.Store.DeleteCourseInstructor">
      <EndProperty Name="Course">
        <ScalarProperty Name="CourseID" ParameterName="courseId"/>
      </EndProperty>
      <EndProperty Name="Person">
        <ScalarProperty Name="PersonID" ParameterName="instructorId"/>
      </EndProperty>
    </DeleteFunction>
  </ModificationFunctionMapping>
</AssociationSetMapping>

参照

その他のリソース

CSDL、SSDL、および MSL 仕様
モデリングとマッピング (Entity Framework)