ServiceFeatureTable Where clause replacement in .NET 100.0.X arcgisRuntime

916
2
Jump to solution
10-16-2020 09:30 AM
KoryKarr
New Contributor

I'm upgrading from arcgisRuntime  .NET SDK 10.2.5 to 100.9.0. I am trying to find a suitable replacement for code like this:

string whereClause = "RouteID = 100" //Actually changes based on user interaction

ServiceFeatureTable serviceFeatureTable = featureLayer.FeatureTable as ServiceFeatureTable;
serviceFeatureTable.Where = whereClause;
serviceFeatureTable.RefreshFeatures(false);

The intent is we only show a handful (usually only 1) of the features in the feature layer. The where clause is actually built dynamically based on what the user is doing. The closest I can find is setting visibility on the features, but first I have to find all the other features and set their visibility as false:

//Hide All Features

QueryParameters queryParams = new QueryParameters();
queryParams.WhereClause = "1 = 1";
queryParams.MaxFeatures = Int32.MaxValue; //Doesn't seem to work
FeatureQueryResult allFeatures = await featureLayer.FeatureTable.QueryFeaturesAsync(queryParams);

long l = allFeatures.Count(); // Just for debugging

featureLayer.SetFeaturesVisible(allFeatures.ToList(), false);

//Show features matching query

string whereClause = "RouteID = 100"

queryParams = new QueryParameters();
queryParams.WhereClause = whereClause;
FeatureQueryResult filterResults = await featureLayer.FeatureTable.QueryFeaturesAsync(queryParams);

featureLayer.SetFeaturesVisible(filterResults.ToList(),true);


And this actually doesn't work either because it looks like the max number of features returned is 1000. It also seems very inefficient. Is there more straightforward way of hiding all the features except those that match a SQL type query?

0 Kudos
1 Solution

Accepted Solutions
Nicholas-Furness
Esri Regular Contributor

Sounds like you're looking for DefinitionExpression. This will only retrieve the feature(s) you're interested in. Note that this is also exposed through the FeatureLayer, in case that is a more logical place for you to set it.

View solution in original post

2 Replies
Nicholas-Furness
Esri Regular Contributor

Sounds like you're looking for DefinitionExpression. This will only retrieve the feature(s) you're interested in. Note that this is also exposed through the FeatureLayer, in case that is a more logical place for you to set it.

KoryKarr
New Contributor

Yes, that works. Also exposing it on the layer simplifies a bunch of code. Thank you!

0 Kudos