New Posts New Posts RSS Feed: Related entities count invalid after delete.
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Related entities count invalid after delete.

 Post Reply Post Reply
Author
rhaney View Drop Down
Newbie
Newbie


Joined: 06-Jul-2010
Location: Orange, CA
Posts: 12
Post Options Post Options   Quote rhaney Quote  Post ReplyReply Direct Link To This Post Topic: Related entities count invalid after delete.
    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.
 
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down