Print Page | Close Window

Related entities count invalid after delete.

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2221
Printed Date: 30-Aug-2025 at 12:44am


Topic: Related entities count invalid after delete.
Posted By: rhaney
Subject: Related entities count invalid after delete.
Date Posted: 09-Oct-2010 at 12:56pm
I have a scenario that does something like the following:
 
1) Launches a read-only screen with a grid that displays a Customer, including related orders via AddIncludePaths("Orders").  This screen displays a count of the orders in the grid via customer.Orders.Count(), using a value converter. 
 
2) Launches a new screen, with a new entity manager, that allows editing of the Customer and related Orders, where orders can be added or removed and changes are saved.
 
3) Refreshes the data on the first screen, once finished with the second.  The count of orders, however, is not consistent with the changes.
 
If I start with 2 orders, add 6 and refresh the read only screen, I will get a total of eight orders.  If I return to the screen and delete the 6 I just added, and refresh again, the total of 8 remains.
 
Results are the same, even if I change the QueryStrategy on the first screen to DataSourceOnly.
 
If I clear the read only screen's entity manager before the refresh, the count is correct.
 
If I remove the customer and their orders from the read only screen's entity manager and refresh, the count is correct as well.
 
My guess is DELETED entities are not taken into account when refreshing?  What would happen if you deleted an order via SQL Mgmt Studio and attempted a refresh?  It seems like it would be possible to use the set of orders retrieved from the data source to determine what has been deleted.
 
What are the scenarios where it would be desirable to retain the entities in cache, that were deleted from the source?
 
I'd like to be able to just refresh, bind the datagrid again, and be done.
 



Replies:
Posted By: DenisK
Date Posted: 12-Oct-2010 at 12:03pm
Hi Ryan;

What environment are you in? And what exactly do you mean by refresh?

I was able to build something similar to the app you described but was not able to reproduce your issue. When I deleted an Order and call SaveChangesAsync from the second screen, it immediately removed the Order from this second screen. When I closed this screen and returned back to the first screen, I did a browser refresh and saw that the deleted Order was removed.



Print Page | Close Window