entities disappearing from a collection?

Posts   
 
    
nilsey
User
Posts: 54
Joined: 11-Jan-2008
# Posted on: 17-Jul-2008 19:07:18   

Just gonna put this out there because I have no idea why this is happening..... if you have any insights they would be welcome.

I have a entity collection:

    Public Property SelectedQuestionGroupAssignments() As EvidenceQuestionGroupAssignmentCollection
...

when I go into the collection and set one of the related entities (the EvidenceQuestionGroupAssignment eqga.Evidence field), the EvidenceQuestionGroupAssignment eqga disappears from the collection.

                    Dim eqga As EvidenceQuestionGroupAssignmentEntity = Me.SelectedQuestionGroupAssignments(questionGroupListItem.DataItemIndex)
                    .....
                    eqga.Evidence = Me.Evidence

again, when I debug and step thru my code ( I'm iterating thru the collection) when I get to that last line, my collection count decreases by one and the eqga is gone from the collection....

so.... any ideas? I'm not sure why setting the field would cause the entity to be removed from the collection.....

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-Jul-2008 05:07:39   

Hi nilsey,

I'm not sure I understand 100% your question. However it's likely a PK-FK sync matter. If you add an Entity X from collection A to collection B, the collection B is notified that it should deference X. I think that is your problem. It's recommended to "clone" the entity and add the cloned one to collection B.

There are a lot of threads covering that subject, this is one of those. And this using serialization.

David Elizondo | LLBLGen Support Team