New Entity Referencing and TreeView Tags

Posts   
 
    
Posts: 2
Joined: 14-Feb-2005
# Posted on: 08-Jun-2005 20:08:41   

Hi,

I have a table which contains nodes for a heirarchical TreeView, each Node having a parent relationship to an entity in the same table. Each node entity has a number of weak linked entities with attributes for each node, and an enumerated Type field which is used by a factory to return an appropriate user control for the node, which populates from the appropriate related attribute entity. The TreeView is being built recursively from a root Node entity.

The aim is to build the entire tree (and navigate around it) and then save the tree recursively from the root node with Save(true). This seems to be working for the tree itself, but not the attribute entities.

When creating a node, the dialog returned from the factory creates a new attribute entity and populates the gui with default values... this is via direct referencing of the attribute entity with the default ReturnNewIfNotFound behaviour. When another node is selected, a function transfers the gui values to the attribute entity, the hope being that the new entity which is related now to a lazy node entity still referenced in the tag on the TreeNode will be preserved for repopulating a form by the factory when it is clicked on again.

What is happening instead though, is that the Node entity seems to maintain a reference (and all it's values), but on a repopulation, the newly created related attribute entity is no longer there, and so another new entity is created. Either the garbage collector is getting to the attribute entities... or I'm missing someting pretty basic... or both wink

Could this be because when retrieving the NodeEntity from the TreeNode, I have to typecase the entity?

I'm thinking that maybe by tagging the TreeNodes with a struct which contains the user control classes (which will maintain references to the attribute entities) and the Node entity might do the trick, but I would be interested first to understand why this isn't working as I intend it.

Configuration is Self Servicing.

Regards.

Simon.

Posts: 2
Joined: 14-Feb-2005
# Posted on: 09-Jun-2005 07:18:16   

.... hmmm.

Apparently I wasn't checking if the record was a new record and was re-initialising attribute values on a fetch.

Nothing to see here....

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 09-Jun-2005 09:08:04   

Glad it's solved! simple_smile

Frans Bouma | Lead developer LLBLGen Pro