.net ArcGis更新功能返回"无法在此上下文中调用此方法:您必须在编辑之前加载该功能。"

时间:2017-05-22 11:16:23

标签: .net arcgis

我试图通过.Net更新要素图层的属性。但我不断收到此错误消息:"无法在此上下文中调用此方法:您必须在编辑之前加载该功能。" 这是我的代码:

static void Main(string[] args) {

  var featureTable = new ServiceFeatureTable(new Uri("https://services7.arcgis.com/yixziXsHssbXEWl5/ArcGIS/rest/services/grex/FeatureServer/0")) {Credential = new ArcGISTokenCredential()};

  ((TokenCredential) featureTable.Credential).Token = GetToken().access_token;
  var queryParams = new QueryParameters {WhereClause = "DeelplanId = 666"};

  // Query the feature table 
  var queryResult =  featureTable.QueryFeaturesAsync(queryParams);
  // Cast the QueryResult to a List so the results can be interrogated
  queryResult.Wait();
  var features = queryResult.Result.ToList();

  features[0].SetAttributeValue("Kosten", 3562);

  Console.ReadKey();
}

它在SetAttributeValue上失败,虽然我看到属性是从服务器加载的。 任何想法?,thx!

1 个答案:

答案 0 :(得分:0)

必须加载该功能:

var editFeature = features.First(); await(editFeature as ArcGISFeature).LoadAsync(); editFeature.SetAttributeValue(“description”,$“从运行时更新{DateTime.Now.ToShortTimeString()}”);

https://geonet.esri.com/thread/195459-update-feature-returns-cannot-call-this-method-in-this-context-you-must-load-the-feature-before-editing