Refreshing data in entity collection

Posts   
 
    
mjperlini
User
Posts: 5
Joined: 12-Feb-2007
# Posted on: 12-Feb-2007 03:41:10   

Hello

I have an entity collection into which I load records as they are accessed (using DataAccessAdapter). I don't delete them from the collection (so that if a user goes back to a record, it is still in memory). I am using the FetchEntityCollection routine with a filter to just load the records that I need.

The problem I am having is that if I change a record (in a dialog), I can save it to the database, but then when I try to refresh the collection, the old data remains in the collection (i.e., it does not override the existing data). If I clear the entity collection first, the new data is loaded correctly.

Is there some setting that I should be using to ensure that the newly loaded items overwrite the old items?

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 12-Feb-2007 07:24:01   

That's by design, since the EntityCollection.DoNotPerformAddIfPresent is set to true by default, and it compares entities by their PK.

So either clear the collection or remove the old entity from the collection before re-fetching. Or set DoNotPerformAddIfPresent to false, and you will have the old entity and the new one.

Otherwise, you may want to use a Context object. Please refer to the LLBLGen Pro manual: "Using the generated code -> Adapter -> Using the context"