Multiple Queries

709
3
06-19-2012 02:36 PM
TanyaOwens
Occasional Contributor III
Currently when I work with multiple queries I setup the first query and then when I add the second I add a "2" to certain parts of the code (see code below). I am new to programing and silverlight and I am thinking this might not be the most effective way to set up multiple queries. So far I have only set up multiple queries that go to separate results and displayed on separate datagrids. I am trying to setup an attribute query and from those results do a spatial query to see which of the queried polygons intersect with my address location points. I am unsure on how to integrate the attribute query and the spatial query to output to a single datagrid. Any help would be appreciated.

Current multiple query code:
First query:
                QueryTask queryTask = new QueryTask("mapserver web address");
                queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
                queryTask.Failed += QueryTask_Failed;

                // Bind data grid to query results
                Binding resultFeaturesBinding = new Binding("LastResult.Features");
                resultFeaturesBinding.Source = queryTask;
                QueryDetailsDataGrid.SetBinding(DataGrid.ItemsSourceProperty, resultFeaturesBinding);
                Query query = new ESRI.ArcGIS.Client.Tasks.Query();
                query.OutSpatialReference = MyMap.SpatialReference;
                
                // Specify fields to return from query
                query.OutFields.AddRange(new string[] { "OBJECTID","Name", "Phone", "TTYPhone", "WebAddress", "Charge" });
                query.Geometry = bestCandidate.Location;
                //query.Geometry = args.Geometry;

                // Return geometry with result features
                query.ReturnGeometry = true;


                queryTask.ExecuteAsync(query);


Second query:
                QueryTask queryTask2 = new QueryTask("mapserver web address");
                queryTask2.ExecuteCompleted += QueryTask_ExecuteCompleted2;
                queryTask2.Failed += QueryTask_Failed2;

                // Bind data grid to query results
                Binding resultFeaturesBinding2 = new Binding("LastResult.Features");
                resultFeaturesBinding2.Source = queryTask2;
                QueryDetailsDataGrid2.SetBinding(DataGrid.ItemsSourceProperty, resultFeaturesBinding2);
                Query query2 = new ESRI.ArcGIS.Client.Tasks.Query();
                query2.OutSpatialReference = MyMap.SpatialReference;
               
                // Specify fields to return from query
                query2.OutFields.AddRange(new string[] { "OBJECTID","Name", "Phone", "TTYPhone", "WebAddress", "Charge" });
                query2.Geometry = bestCandidate2.Location;
                //query.Geometry = args.Geometry;

                // Return geometry with result features
                query2.ReturnGeometry = true;


                queryTask2.ExecuteAsync(query2);


Thanks!
0 Kudos
3 Replies
TanyaOwens
Occasional Contributor III
In addition to my above post, for the current spatial query I am using the address location point as the Query.Geometry but I also need to be querying the results of the attribute query...I have no clue how to work this out in the code. Is it possible to have two components to the Query.Geometry?
0 Kudos
LanceGoens
New Contributor III
I am in a similar situation where I need to execute multiple queries sequentially and I'm not sure how to handle the results. Can you share how you resolved your issue?
0 Kudos
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
What about creating a GP Service that would execute both of your queries and return the results.  You could then bind the results to your datagrid.
0 Kudos