Hi,
I am trying to edit a file geodatabase that is referenced from a map package that I load through a LocalFeatureService. The file geodatabase is not within the map package, it is referencing the file geodatabase which resides elsewhere on disk. Note that due to our workflow, using the SQLite-based .geodatabase format is not an option.
I am able to create a MapPoint and add it to the ServiceFeatureTable that represents the points that exist as a feature class in the file geodatabase. I can apply my edits and it shows up in my map and in ArcMap when the file geodatabase is loaded there.
However, I can't seem to edit attributes in code. Below is a summary of my code:
//set up our service and all tables and feature layers LocalFeatureService _lfs = await LocalFeatureService.StartAsync(@"D:\dev\HelloWorldMap\HelloWorldMap\Assets\Data\test.mpk"); var url = _lfs.UrlFeatureService; ServiceFeatureTable _sft = await ServiceFeatureTable.OpenAsync(new Uri(url + "/0"), null, SpatialReference.Create(3857)); _pointsLayer = new FeatureLayer { ID = "Points", DisplayName = "Points", FeatureTable = _sft }; //add the point layer to the map MyMap.Layers.Add(_pointsLayer); //create a feature using the ServiceFeatureTable's schema...the schema shows the proper fields. var feature = new GeodatabaseFeature(_sft.Schema); //after this line and before line 21, feature.Attributes is an empty dictionary! var point = new MapPoint(0, 0); feature.Geometry = point; //add the feature to the file geodatabase long id = await _sft.AddAsync(feature); //At this point feature.Attributes only shows OBJECTID in the dictionary collection, and it's value is -10 //No other attributes are showing even though the feature.Schema shows all proper fields! //oh well, let's commit anyway. After this call, the point is added //permanently to the geodatabase, it's OBJECTID is set as expected, and all other fields are <null>. var editResult = await _sft.ApplyEditsAsync();
I should add that I tried to manually recreated the Attribute key/value pairs from the schema, populate them, and commit, but that did not work. No exceptions, just the changes were ignored.