private static async Task <EditResult <T> > ApplyEdits <T>(this ILayer <T> layer, T[]?featuresToAdd = null, T[]?featuresToUpdate = null, T[]?featuresToDelete = null) where T : Feature { var adds = featuresToAdd?.Select(f => f.ToGraphic(layer.LayerInfo, false)).ToArray(); var updates = featuresToUpdate?.Select(f => f.ToGraphic(layer.LayerInfo, true)).Where(o => o is not null).ToArray(); var deletes = featuresToDelete?.Select(f => f.OID).ToArray(); var editResultSet = await Esri.ApplyEdits(layer.Url, layer.Token, adds, updates, deletes); if (editResultSet.error is null) { foreach (var f in featuresToUpdate ?? Array.Empty <T>()) { f.IsDirty = false; } foreach (var f in featuresToDelete ?? Array.Empty <T>()) { f.OID = -1; f.IsDirty = false; } } return(new EditResult <T>(editResultSet, layer)); }