Hello
I am looking for a way to clear the loaded state of all Navigation Properties in an EntityManager so that lazy loading works as normal when a query is being re-executed.
Here is an example of what I'm doing. I execute a query to get a list of OrderDetail which is bound into a GridView. The gridview has a column that displays the OrderDetail.Order.Id of each OrderDetail and also the Customer Name (OrderDetail.Order.Customer.Name) for the Order. With lazy loading turned on, the binding to OrderDetail.Order retrieves the Order Entity. And binding to Order.Customer retrieves the Customer Entity.
Everything so far is good. But after some period of time, I want to be able to refresh the whole grid. With lazy loading turned on, DevForce will only refetch the OrderDetail list. It never refetches the related OrderDetail or Customer Entities. I have even tried clearing the QueryCache and it still won't refetch the related entities.
I know there is a EntityReferenceStrategy that can be set to "Load" instead of "Lazy" but this completely negates the use of the cache (every reference to a navigation property will always go to the database even in it has already been fetched and is in the query cache). I also know you can set the IsLoaded property in the metadata for an entity's NavigationProperty but this requires me to loop through all the entities in my list to set this (and any other nested properties (i.e. Order to Customer, etc.)). Depending upon how many nested navigations you use, this is not practical.
So, is there an easy way to tell the EntityManager to basically forget (or reset) all navigation properties so that when referenced, they will be lazy loaded again (only once)?
Thanks!