Refetching a collection

Posts   
 
    
stoney77
User
Posts: 10
Joined: 18-Jul-2008
# Posted on: 10-Dec-2010 10:44:13   

We are using LLblgen self servicing to create all our entities. Our main entity is known as MatterEntity it is obtained using the SD.LLBLGen.Pro.ORMSupportClasses.Context. This works great for most of our scenarios. Unfortunately, the scenario we are having problems with is when we build a screen to edit a collection class that hangs off MatterEntity such as a AdditionalInformationCollection. We can add/remove items and edit.

We need to give the user a cancel option which will cancel the changes. We tried this by calling the llblgen generated methods on MatterEntity like

GetMultiAdditionalInformation(bool forceFetch)

we set the forcefetch to true and it got rid of the changes and reloaded the items, it worked great for entities that were aded and removed, unfortunately because we were using the Context class it checked if items existed in the context when it ran. This had the effect of keeping the original edits as the entities existed within the context.

After looking into the Context class we found a property called:

SetExistingEntityFieldsInGet

We assumed this would sort out the problem and force the reload of all entities from the database without checking the context. It didn't work and when we browsed the source code found that it only gets applied when the entity is NOT dirty.

Can anyone offer any suggestions on the best way to achieve this. We were thinking about creating our own method in a MatterEntity partial class that called GetMultiAdditionalInformation(bool forceFetch) and then looped through each entity and called refetch if the entity was dirty. Although this would not be performant for a user whom has made changes to a lot of entities in that collection and then clicks cancel.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 10-Dec-2010 12:36:38   

Which LLBLGen Pro runtime library version (build no.) are you using?

stoney77
User
Posts: 10
Joined: 18-Jul-2008
# Posted on: 10-Dec-2010 12:43:57   

Version 3

Thanks, Stephen

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 10-Dec-2010 12:57:43   

We need the build number, please check this thread: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7722

Please explain why are using a context, as it was not designed to be used as a cache. What hapens if you clear the context and refetch the entities and add them to the context again, would this be possible (business wise).

stoney77
User
Posts: 10
Joined: 18-Jul-2008
# Posted on: 10-Dec-2010 13:10:44   

Build: 3.0.10.907

We are using the Context for keeping unique versions of all entities. The MatterEntity has a long lifespan and everything hangs off it. Its just that when a user cancels a change we want to reload the related collection completely from the database and still keep the unique nature of the context.

Thanks

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 10-Dec-2010 22:34:53   

I think that re-assigning a new Context, or clear the current Context should work.

David Elizondo | LLBLGen Support Team