AnsweredAssumed Answered

Adding a feature layer via Geodatabase

Question asked by mark.gumban on May 15, 2018
Latest reply on Oct 16, 2018 by

I'm using the following code to open a connection to a feature server and adding a feature layer to the current map:

var serviceUrl = @"http://url-of-feature-server/FeatureServer";
var layerId = "0";
var map = MapView.Active.Map;

using (var geoDb = new Geodatabase(new ServiceConnectionProperties(new Uri(serviceUrl)))
  var defNames = geoDb.GetDefinitions<FeatureClassDefinition>()
    .Select(def => def.GetName()).ToArray();
  var id = int.Parse(layerId);
  Debug.Assert(defNames.Length > id);
  if (defNames.Length > id)
    using (var featureClass = geoDb.OpenDataset<FeatureClass>(defNames[id]))
      featureLayer = LayerFactory.Instance.CreateFeatureLayer(featureClass, map);


This works fine the 1st time this code gets executed.  If the feature server has N feature layers then defNames gets N definitions.


If the feature server gains a new layer, one would expect that the next time this code gets executed defNames would have N + 1 items.  However it still returns N definitions.  Using Fiddler, I can see that ArcGIS performs HTTP requests (to get feature definitions, metadata, etc.) the 1st time the Geodatabase object is created.  Subsequent creations of new Geodatabase objects (using the same service URL) does not make any other HTTP requests, even when geoDb object was disposed via "using", as if it was being cached by ArcGIS.  


I would like to ensure that every time I create a new Geodatabase object that it has the most recent feature definitions and ArcGIS doesn't cache anything.  How would one do that?


Additionally, I've noticed that SetDisplayCacheType(DisplayCacheType.None) does not seem to apply or update the layer's properties (checking via Layer->Properties->Cache).