DeleteFunction 要素 (MSL)
マッピング スキーマ言語 (MSL) の DeleteFunction 要素は、概念モデル内のエンティティ型またはアソシエーションの削除関数を、基になるデータベースのストアド プロシージャにマップします。 変更関数のマップ先であるストアド プロシージャは、ストレージ モデル内で宣言する必要があります。 詳細については、「Function 要素 (SSDL)」を参照してください。
注 : |
---|
エンティティ型の挿入、更新、および削除の 3 つの操作をすべてストアド プロシージャにマップしないと、マップされていない操作は実行時に失敗して UpdateException がスローされます。 |
EntityTypeMapping への DeleteFunction の適用
DeleteFunction 要素は、EntityTypeMapping 要素に適用されると、概念モデル内のエンティティ型の削除関数をストアド プロシージャにマップします。
The DeleteFunction element can have the following child elements when applied to an EntityTypeMapping element:
AssociationEnd (0 個以上)
ComplexProperty (0 個以上)
ScarlarProperty (0 個以上)
適用可能な属性
次の表は、EntityTypeMapping 要素に適用する場合に DeleteFunction 要素に適用できる属性を示しています。
属性名 | 必須 | Value |
---|---|---|
FunctionName |
有効 |
削除関数のマップ先となるストアド プロシージャの名前空間修飾名。 ストアド プロシージャはストレージ モデル内で宣言する必要があります。 |
RowsAffectedParameter |
いいえ |
影響を受ける行の数を返す出力パラメーターの名前。 |
例
次の例は、School モデルに基づいており、Person エンティティ型の削除関数を DeletePerson ストアド プロシージャにマップする DeleteFunction 要素を示しています。 The DeletePerson stored procedure is declared in the storage model.
<EntitySetMapping Name="People">
<EntityTypeMapping TypeName="SchoolModel.Person">
<MappingFragment StoreEntitySet="Person">
<ScalarProperty Name="PersonID" ColumnName="PersonID" />
<ScalarProperty Name="LastName" ColumnName="LastName" />
<ScalarProperty Name="FirstName" ColumnName="FirstName" />
<ScalarProperty Name="HireDate" ColumnName="HireDate" />
<ScalarProperty Name="EnrollmentDate"
ColumnName="EnrollmentDate" />
</MappingFragment>
</EntityTypeMapping>
<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>
</EntitySetMapping>
AssociationSetMapping への DeleteFunction の適用
DeleteFunction 要素は、AssociationSetMapping 要素に適用されると、概念モデル内のアソシエーションの削除関数をストアド プロシージャにマップします。
The DeleteFunction 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 DeleteFunction element when it is applied to the AssociationSetMapping element.
属性名 | 必須 | Value |
---|---|---|
FunctionName |
有効 |
削除関数のマップ先となるストアド プロシージャの名前空間修飾名。 ストアド プロシージャはストレージ モデル内で宣言する必要があります。 |
RowsAffectedParameter |
いいえ |
影響を受ける行の数を返す出力パラメーターの名前。 |
例
次の例は、School モデルに基づいており、CourseInstructor アソシエーションの削除関数を DeleteCourseInstructor ストアド プロシージャにマップするために使用される DeleteFunction 要素を示しています。 The DeleteCourseInstructor 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>