Skip to content

Commit 271082d

Browse files
authored
FeatureLayer Query sample - Format search terms (#346)
* FeatureLayer Query remove white space from search term * Format search terms in QueryFeature Layer
1 parent 9528945 commit 271082d

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

src/Android/Xamarin.Android/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private async Task QueryStateFeature(string stateName)
105105
QueryParameters queryParams = new QueryParameters();
106106

107107
// Construct and assign the where clause that will be used to query the feature table
108-
queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + (stateName.ToUpper()) + "%'";
108+
queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + (stateName.Trim().ToUpper()) + "%'";
109109

110110
// Query the feature table
111111
FeatureQueryResult queryResult = await _featureTable.QueryFeaturesAsync(queryParams);

src/UWP/ArcGISRuntime.UWP.Samples/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,11 @@ private async Task QueryStateFeature(string stateName)
9090
// Create a query parameters that will be used to Query the feature table
9191
QueryParameters queryParams = new QueryParameters();
9292

93+
// Trim whitespace on the state name to prevent broken queries
94+
String formattedStateName = stateName.Trim().ToUpper();
95+
9396
// Construct and assign the where clause that will be used to query the feature table
94-
queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + (stateName.ToUpper()) + "%'";
97+
queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + formattedStateName + "%'";
9598

9699
// Query the feature table
97100
FeatureQueryResult queryResult = await _featureTable.QueryFeaturesAsync(queryParams);

src/WPF/ArcGISRuntime.WPF.Samples/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,11 @@ private async Task QueryStateFeature(string stateName)
9090
// Create a query parameters that will be used to Query the feature table
9191
QueryParameters queryParams = new QueryParameters();
9292

93+
// Trim whitespace on the state name to prevent broken queries
94+
String formattedStateName = stateName.Trim().ToUpper();
95+
9396
// Construct and assign the where clause that will be used to query the feature table
94-
queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + (stateName.ToUpper()) + "%'";
97+
queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + formattedStateName + "%'";
9598

9699
// Query the feature table
97100
FeatureQueryResult queryResult = await _featureTable.QueryFeaturesAsync(queryParams);

src/iOS/Xamarin.iOS/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,11 @@ private async Task QueryStateFeature(string stateName)
127127
// Create a query parameters that will be used to Query the feature table
128128
QueryParameters queryParams = new QueryParameters();
129129

130+
// Trim whitespace on the state name to prevent broken queries
131+
String formattedStateName = stateName.Trim().ToUpper();
132+
130133
// Construct and assign the where clause that will be used to query the feature table
131-
queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + (stateName.ToUpper()) + "%'";
134+
queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + formattedStateName + "%'";
132135

133136
// Query the feature table
134137
FeatureQueryResult queryResult = await _featureTable.QueryFeaturesAsync(queryParams);

0 commit comments

Comments
 (0)