.net ArcGis 更新功能 returns "Cannot call this method in this context: You must load the feature before editing."
.net ArcGis update feature returns "Cannot call this method in this context: You must load the feature before editing."
我正在尝试通过 .Net 更新要素图层的属性。但我不断收到此错误消息:"Cannot call this method in this context: You must load the feature before editing."
这是我的代码:
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 上失败了。
有什么想法吗?谢谢!
必须加载功能:
var editFeature = features.First();
await (editFeature as ArcGISFeature).LoadAsync();
editFeature.SetAttributeValue("description", $"Updated from runtime at {DateTime.Now.ToShortTimeString()}");
我正在尝试通过 .Net 更新要素图层的属性。但我不断收到此错误消息:"Cannot call this method in this context: You must load the feature before editing." 这是我的代码:
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 上失败了。 有什么想法吗?谢谢!
必须加载功能:
var editFeature = features.First(); await (editFeature as ArcGISFeature).LoadAsync(); editFeature.SetAttributeValue("description", $"Updated from runtime at {DateTime.Now.ToShortTimeString()}");