Multiple Relationship Queries on a single QueryTask

2188
6
Jump to solution
02-01-2012 09:39 AM
Labels (1)
HeatherMeadow
New Contributor
I am new to ArcGIS and I am trying to query related records for two separate tables on a single feature. My problem is that when a relationship query is executed, I do not know which relationship completed in the event handler. Is there a way to determine which relationship has been executed within the QueryTask_ExecuteRealtionshipQueryCompleted event? That is without having to hard code it and look for the exact attributes returned from the query.

Any help or solutions would be appreciated.

Thanks!

Heather
0 Kudos
1 Solution

Accepted Solutions
JenniferNery
Esri Regular Contributor
Sure, you can use UserToken to save any object that you want retrieved in the Completed event.

For example, from this SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#QueryRelatedRecords, you can add the following code.
                           queryTask.ExecuteRelationshipQueryAsync(relationshipParameters, relationshipParameters);             }         }   void QueryTask_ExecuteRelationshipQueryCompleted(object sender, RelationshipEventArgs e)   {    var rp = e.UserState as RelationshipParameter;   }

View solution in original post

0 Kudos
6 Replies
JenniferNery
Esri Regular Contributor
Sure, you can use UserToken to save any object that you want retrieved in the Completed event.

For example, from this SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#QueryRelatedRecords, you can add the following code.
                           queryTask.ExecuteRelationshipQueryAsync(relationshipParameters, relationshipParameters);             }         }   void QueryTask_ExecuteRelationshipQueryCompleted(object sender, RelationshipEventArgs e)   {    var rp = e.UserState as RelationshipParameter;   }
0 Kudos
HeatherMeadow
New Contributor
Thank you! That worked great!
0 Kudos
JasonSweet
New Contributor
I'm not new to Arc, but definitely not a programmer.  Could you give the code that would be used in VB?
0 Kudos
JasonSweet
New Contributor
A little more infor on what I'm hoping to do.

I started with the TreeView referenced above.  Because I'm querying related record in three tables from the selected feature, I made the RelatedRowsDataGrid a TabControl; one tab for each related table.  The multiple async queries seem to be working now using code similar to that above, but I'm having problems populating the 2nd and 3rd tabs with the info from those relationship queries.

Any ideas would be greatly appreciated.

Thanks
0 Kudos
JenniferNery
Esri Regular Contributor
The SDK samples have VB version as well. As for the code below, you can try online conversion C# to VB. I think you're the same person that posted in Silverlight forum. It sounds like you're making progress already 🙂
0 Kudos
JasonSweet
New Contributor
Progress, yes.  I need to beef up my VB.  Thanks for the help.
0 Kudos