//add
var graphic = new Graphic() {Geometry = new MapPoint(x,y)}
graphic.Attributes["fieldName"] = fieldValue;
featureLayer.Graphics.Add(graphic);
//remove
graphic = featureLayer.Graphics.FirstOrDefault(g => (int)g.Attributes[layer.LayerInfo.ObjectIdField] == idToDelete);
if (graphic != null) featureLayer.Graphics.Remove(graphic);
//edit
graphic = featureLayer.Graphics.FirstOrDefault(g => (int)g.Attributes[layer.LayerInfo.ObjectIdField] == idToEdit);
graphic.Geometry = new MapPoint(x,y);
graphic.Attributes["fieldName"] = newFieldValue;
FeatureLayer l = new FeatureLayer()
{
Url = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/FeatureServer/0" ,
ObjectIDs = new int[]{11688}
};
l.OutFields.Add("*");
l.Initialized += (s, e) =>
{
if (l.InitializationFailure == null)
l.Update();
};
l.UpdateCompleted += (s, e) =>
{
var graphic = l.Graphics.FirstOrDefault(g => (int)g.Attributes[l.LayerInfo.ObjectIdField] == 11688);
if (graphic != null)
graphic.Attributes["description"] = string.Format("Updated this field on {0}", DateTime.UtcNow);
};
l.EndSaveEdits += (s, e) =>
{
if(e.Results!= null || e.Results.UpdateResults!=null)
{
foreach (var r in e.Results.UpdateResults)
MessageBox.Show(string.Format("Updated id ({0})", r.ObjectID));
}
};
l.Initialize();
//remove
graphic = featureLayer.Graphics.FirstOrDefault(g => (int)g.Attributes[layer.LayerInfo.ObjectIdField] == idToDelete);
if (graphic != null) featureLayer.Graphics.Remove(graphic);