Duplicate Entities in Collection

Posts   
 
    
tprohas
User
Posts: 257
Joined: 23-Mar-2004
# Posted on: 23-Mar-2006 20:15:05   

Can anyone tell me why I can't add two of the same entity to a collection and then use foreach to iterate over the collection and get the two entities back out. It seems that when I do this I only get one entity back out. The EntityCollection seems to eat up one of the two duplicate entities. This still happens even if I change the value of a property on one of the two entities to make it different.

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 24-Mar-2006 04:16:59   

Are their primary keys the same?

tprohas
User
Posts: 257
Joined: 23-Mar-2004
# Posted on: 28-Mar-2006 00:20:37   

bclubb wrote:

Are their primary keys the same?

Yes, My the primary key for the two entities is the same. I am aware of the fact that I can make this work if I use some type of collection other then an entity collection, but I would prefere to use the entity collection if at all possible.

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 28-Mar-2006 03:04:29   

Set the DoNotPerformAddIfPresent property of the collection to false and you should be able to add the second entity.

tprohas
User
Posts: 257
Joined: 23-Mar-2004
# Posted on: 31-Mar-2006 19:50:19   

Thank you for the info, this has solved my problem.