Child_Insert Parent?

Child_Insert Parent?

Old forum URL: forums.lhotka.net/forums/t/6846.aspx


Frazer posted on Friday, April 24, 2009

Another novice question:

Using my earlier example, I have an editable root object:

RequestPackage - this object represents a request batch that is created by a user, fulfilled and managed as a aggregate work package.  Sample properties would include:

RequestPackageID
UserID
RequestPackageName
Requests   <-- this is a list of editable child objects

Then have a Requests object:  editable child list of Request

Request:  editable child object.

My question is, in the Child_Update method of the Request child object, what should be specified for the parent argument:  RequestPackage or Requests?

Frazer

Marjon1 replied on Friday, April 24, 2009

In the request object the parent would be the Requests list; the Requests list (editable listbase) parent object would be the RequestPackage.

Normally as part of an insert/update of a child record it is normal to pass in either the id or parent object itself, of the parent root item so the children can use it to setup foreign key constraints.

Frazer replied on Friday, April 24, 2009

Sorry if I am slow on the uptake, but still a bit confused. The use of the word parent is ambiguous to me.

Which is correct in the Request class (child class):

Private Sub Child_Update(ByVal parent As Requests)

or

Private Sub Child_Update(ByVal parent As RequestPackage)

I think the latter, since, as you say, this provides a means to obtain the key of the owning RequestPackage to establish the FK in the database.

If I understand the pattern correctly, there is nothing in the code of the Request (child) class which explicitly identifies its parent collection: Requests.  Am I correct in this?

Frazer

 

ajj3085 replied on Friday, April 24, 2009

If you're using FieldManager.UpdateChildren, you can pass whatever you want. As long as the child has a matching signature, it will work.

Copyright (c) Marimer LLC