Select to view content in your preferred language

Feature Layer Save Bug?

2265
0
03-18-2013 01:01 PM
RobChouinard
Frequent Contributor
In Silverlight API 3.1 I encountered this possible bug trying to save a feature layer created in code-behind.

All in code-behind:

  • Create a new FeatureLayer with where = "1<>1".

  • Initialize and Update feature layer in that order and wait for those to complete.

  • Create a new graphic and add it to the feature layer.

  • Remove graphic from feature layer.

  • FeatureLayer.HasEdits returns with true, now call FeatureLayer.SaveEdits().

  • SaveEditsFailed, EndSaveEdits, BeginSaveEdits events are never fired.

The bug is: although FeatureLayer.HasEdits = true, it in fact does not have any edits. So I check to see if it has edits, and it falsely returns that it does so I call SaveEdits() and I'm using something like a wait indicator letting the user know to hold up while I save this. And the wait is for infinity because SaveEditsFailed, EndSaveEdits, BeginSaveEdits events are never fired.

My workaround is to call FeatureLayer.UndoEdits(Graphic), check if FeatureLayer.Graphics contains Graphic and delete if so, then HasEdits returns correctly and I can skip saving if there is in-fact no edits to save. The UndoEdits works well in the scenario above because it removes the newly added graphic and correctly sets the HasEdits to false.

Rob
0 Kudos
0 Replies