First of all, the IncludeInFormDelete is only be concerned with the current records. So I would set this back to the PrimaryBusinessObject. Next, I would handle the deletion of the child in the AfterDelete event of the primary business object. Generally what I do is get a list of all of the children PKs that I want to delete, the cycle through and delete them all. You could also create a command in the child BO that uses parameters to delete all of the children:Public Function DeleteChildrenRecords(Byval ParentPrimaryKey As Integer) As Integer
Dim loCommand As New SQLCommand
'-- Create the command
loCommand.CommandText = "DELETE FROM MyTable WHERE MyField_ParentPK = @MyField_ParentPK"
'-- Create the parms
loCommand.Parameters.Add("@MyField_ParentPK", SqlDbType.Int)
'-- Set the parms
loCommand.Parameters("@MyField_ParentPK").Value = ParentPrimaryKey
'-- Return the number of records deleted
Return Me.ExecuteNonQuery(loCommand)
End Function
So in the BeforeDelete or AfterDelete event of the BO on the form, call the method above:
MyChildBO.DeleteChildrenRecords(Me.MyPrimaryKey)