From 271082d46457de1cf4af6d43a4be73f36241ec33 Mon Sep 17 00:00:00 2001 From: Stuart McIlreavy Date: Tue, 7 Nov 2017 17:11:44 +0000 Subject: [PATCH] FeatureLayer Query sample - Format search terms (#346) * FeatureLayer Query remove white space from search term * Format search terms in QueryFeature Layer --- .../Samples/Data/FeatureLayerQuery/FeatureLayerQuery.cs | 2 +- .../Samples/Data/FeatureLayerQuery/FeatureLayerQuery.xaml.cs | 5 ++++- .../Samples/Data/FeatureLayerQuery/FeatureLayerQuery.xaml.cs | 5 ++++- .../Samples/Data/FeatureLayerQuery/FeatureLayerQuery.cs | 5 ++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Android/Xamarin.Android/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.cs b/src/Android/Xamarin.Android/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.cs index 6cb8be88c0..ac6eebd4d0 100644 --- a/src/Android/Xamarin.Android/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.cs +++ b/src/Android/Xamarin.Android/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.cs @@ -105,7 +105,7 @@ private async Task QueryStateFeature(string stateName) QueryParameters queryParams = new QueryParameters(); // Construct and assign the where clause that will be used to query the feature table - queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + (stateName.ToUpper()) + "%'"; + queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + (stateName.Trim().ToUpper()) + "%'"; // Query the feature table FeatureQueryResult queryResult = await _featureTable.QueryFeaturesAsync(queryParams); diff --git a/src/UWP/ArcGISRuntime.UWP.Samples/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.xaml.cs b/src/UWP/ArcGISRuntime.UWP.Samples/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.xaml.cs index 64213b5f61..a77e160671 100644 --- a/src/UWP/ArcGISRuntime.UWP.Samples/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.xaml.cs +++ b/src/UWP/ArcGISRuntime.UWP.Samples/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.xaml.cs @@ -90,8 +90,11 @@ private async Task QueryStateFeature(string stateName) // Create a query parameters that will be used to Query the feature table QueryParameters queryParams = new QueryParameters(); + // Trim whitespace on the state name to prevent broken queries + String formattedStateName = stateName.Trim().ToUpper(); + // Construct and assign the where clause that will be used to query the feature table - queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + (stateName.ToUpper()) + "%'"; + queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + formattedStateName + "%'"; // Query the feature table FeatureQueryResult queryResult = await _featureTable.QueryFeaturesAsync(queryParams); diff --git a/src/WPF/ArcGISRuntime.WPF.Samples/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.xaml.cs b/src/WPF/ArcGISRuntime.WPF.Samples/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.xaml.cs index 4ec3f333ed..89269a792a 100644 --- a/src/WPF/ArcGISRuntime.WPF.Samples/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.xaml.cs +++ b/src/WPF/ArcGISRuntime.WPF.Samples/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.xaml.cs @@ -90,8 +90,11 @@ private async Task QueryStateFeature(string stateName) // Create a query parameters that will be used to Query the feature table QueryParameters queryParams = new QueryParameters(); + // Trim whitespace on the state name to prevent broken queries + String formattedStateName = stateName.Trim().ToUpper(); + // Construct and assign the where clause that will be used to query the feature table - queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + (stateName.ToUpper()) + "%'"; + queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + formattedStateName + "%'"; // Query the feature table FeatureQueryResult queryResult = await _featureTable.QueryFeaturesAsync(queryParams); diff --git a/src/iOS/Xamarin.iOS/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.cs b/src/iOS/Xamarin.iOS/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.cs index 71a3df4c3f..ad09d45897 100644 --- a/src/iOS/Xamarin.iOS/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.cs +++ b/src/iOS/Xamarin.iOS/Samples/Data/FeatureLayerQuery/FeatureLayerQuery.cs @@ -127,8 +127,11 @@ private async Task QueryStateFeature(string stateName) // Create a query parameters that will be used to Query the feature table QueryParameters queryParams = new QueryParameters(); + // Trim whitespace on the state name to prevent broken queries + String formattedStateName = stateName.Trim().ToUpper(); + // Construct and assign the where clause that will be used to query the feature table - queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + (stateName.ToUpper()) + "%'"; + queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + formattedStateName + "%'"; // Query the feature table FeatureQueryResult queryResult = await _featureTable.QueryFeaturesAsync(queryParams);