This question is locked. New answers and comments are not allowed.
Hi,
I am having trouble using the Context.Refresh method on Entities with child lazy-loaded entities. I would like to have a refresh button which causes all objects to be re-loaded from the database (without creating a new context). Currently, if I have a Person object that has multiple Phone Number objects and a single Address object as lazy loaded properties they lazy-load correctly (i.e. the first access causes a database query). However, if I use the Refresh method, all non-database-object properties of the Person object get refreshed from the database (as expected), however subsequent calls to the Phone Number or Address objects do not cause database queries and load the previously loaded versions of these objects (even if there has been updates to these objects in the database). Is there any way for me to mark the child objects of a database object as null or dirty that will cause them to be reloaded on the next call to their getters?
I have had some success with using the Cache.Release method on the parent object (this causes the single object properties to reload from the database), however it does not seem to work at all with any properties that are lists of database objects.
Thanks,
Ryan
I am having trouble using the Context.Refresh method on Entities with child lazy-loaded entities. I would like to have a refresh button which causes all objects to be re-loaded from the database (without creating a new context). Currently, if I have a Person object that has multiple Phone Number objects and a single Address object as lazy loaded properties they lazy-load correctly (i.e. the first access causes a database query). However, if I use the Refresh method, all non-database-object properties of the Person object get refreshed from the database (as expected), however subsequent calls to the Phone Number or Address objects do not cause database queries and load the previously loaded versions of these objects (even if there has been updates to these objects in the database). Is there any way for me to mark the child objects of a database object as null or dirty that will cause them to be reloaded on the next call to their getters?
I have had some success with using the Cache.Release method on the parent object (this causes the single object properties to reload from the database), however it does not seem to work at all with any properties that are lists of database objects.
Thanks,
Ryan