EditableRootListBase losing its parent reference

EditableRootListBase losing its parent reference

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


tetranz posted on Tuesday, January 22, 2008

Hi Rocky

I've jumped from 3.0.0 to 3.0.3 and I have a EditableRootListBase where I make use of the Parent property in the item's DataPortal_Update. This has been working fine but now the parent is null.

It seems to be related to the cloning change introduced in 3.0.2. I haven't done anything with autoclone so I guess its off by default. I think it loses the parent reference on clone. If I comment out the cloning code around line 90 of ERLB then it works again.

Ross

RockfordLhotka replied on Wednesday, January 23, 2008

It isn't actually valid to use the Parent reference in a DataPortal_XYZ method when the parent is an ERLB. The reason is because it would fail with a remote data portal. The ERLB doesn't transfer to the server in that case - only the root object being saved moves to the server, and so any parent reference would be referencing the ERLB back on the client.

RockfordLhotka replied on Wednesday, January 23, 2008

I suppose I should offer an alternative solution though Smile [:)]

I recommend that you change your code to do any sort of parent-related checks in a Save() override.

And if your DataPortal_Update() method needs some parent information (or sibling information) then in your Save() override needs to copy that data into some temporary state store inside the root object that's being saved.

tetranz replied on Wednesday, January 23, 2008

RockfordLhotka:
It isn't actually valid to use the Parent reference in a DataPortal_XYZ method when the parent is an ERLB. The reason is because it would fail with a remote data portal.

Ahh ... yes that makes sense, Thanks.

Copyright (c) Marimer LLC