Select to view content in your preferred language

ExecuteRelationshipQueryAsync

850
5
06-26-2012 01:50 AM
JudyTroutwine
Regular Contributor
I am doing a straightforward relationship query on a point table.  It worked at one time but, after rebuilding the map service, there might be an issue with the way the relationship is detected.  In ArcMap, the relate is shown correctly in the property page.  The ArcGIS Services Directory in Visual Studio seems to be stating that the layer is related to itself and that the standalone table is related to itself.  Where can I see an example of how the directory displays relationships?
0 Kudos
5 Replies
DominiqueBroux
Esri Frequent Contributor
You can look at how are displayed the relationships with this sample : http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer

If you click on one layer, you will see a description of the relationships for that layer.
0 Kudos
JudyTroutwine
Regular Contributor
I have been able to set up and see both relationship class relates and relates within an MXD in the ArcGIS Services Directory.  I have some functionality that works with the relationship class approach.  With a relate set up in a MXD, queryDomainsTask.ExecuteRelationshipQueryAsync raises an error.  Is there some difference in the RelationshipParameter requirements??

(I copied the ArcGIS Services Directory to an area below the code here.  It shows the relationship with  ID 1.  When doing the query interactively -- on the Query Related Records page, a faint message states "relationshipID (1) not found").

{
...

                           RelationshipParameter relationshipParameters = new RelationshipParameter()
                           {
                             ObjectIds = (int[])ObjIds,
                             DefinitionExpression =  exp,
                             OutFields = new string[] { "OBJECTID, scientific_name, TSN_genus, TSN_species, ITIS_hyperlink" },    
                             RelationshipId = 1,
                             OutSpatialReference = MyMap.SpatialReference
                           };
                               Cursor = Cursors.Wait;
                               queryDomainsTask.ExecuteRelationshipQueryAsync(relationshipParameters);


}



     

Layer: Campus.DBO.Trees (ID: 0)
Display Field: Common_Name

Type: Feature Layer

Geometry Type: esriGeometryPoint

Description:

Definition Expression:

Copyright Text:

Min. Scale: 0

Max. Scale: 0

Default Visibility: True

Extent:

XMin: 846668.441049442
YMin: 982567.050557435
XMax: 849121.810814604
YMax: 985856.730657861
Spatial Reference: 102700

Has Attachments: False

HTML Popup Type: esriServerHTMLPopupTypeAsHTMLText

Drawing Info:

Renderer:

Simple Renderer:
Symbol:

Simple Marker Symbol:
Style: esriSMSCircle, Color: [38, 115, 0, 255], Size: 4, Angle: 0, XOffset: 0, YOffset: 0
Outline
Color: [0, 0, 0, 255], Width: 1
Label:
Description:

Transparency: 0
Labeling Info: N/A

Fields:
OBJECTID (Type: esriFieldTypeOID, Alias: OBJECTID)
UniqueTreeID (Type: esriFieldTypeInteger, Alias: UniqueTreeID)
POINT_XCoord (Type: esriFieldTypeDouble, Alias: POINT_XCoord)
POINT_YCoord (Type: esriFieldTypeDouble, Alias: POINT_YCoord)
POINT_ZCoord (Type: esriFieldTypeDouble, Alias: POINT_ZCoord)
Common_Name (Type: esriFieldTypeString, Alias: Common_Name, Length: 50, Domain: Coded Values: [Alberta spruce: Alberta spruce], [American basswood: American basswood], [American elm: American elm], ...116 more... )
Scientific_Name (Type: esriFieldTypeString, Alias: Scientific_Name, Length: 50 )
Variety (Type: esriFieldTypeString, Alias: Variety, Length: 25 )
TSN_GenusCode (Type: esriFieldTypeDouble, Alias: TSN_GenusCode)
TSN_SpeciesCode (Type: esriFieldTypeDouble, Alias: TSN_SpeciesCode)
Tree_FormType (Type: esriFieldTypeString, Alias: Tree_FormType, Length: 20 )
Tree_Height (Type: esriFieldTypeDouble, Alias: Tree_Height)
Crown_Width (Type: esriFieldTypeDouble, Alias: Crown_Width)
Condition (Type: esriFieldTypeString, Alias: Condition, Length: 20 )
Edit_Status (Type: esriFieldTypeString, Alias: Edit_Status, Length: 10 )
Edit_CreateDate (Type: esriFieldTypeDate, Alias: Edit_CreateDate, Length: 36 )
Edit_ModifyDate (Type: esriFieldTypeDate, Alias: Edit_ModifyDate, Length: 36 )
Editor (Type: esriFieldTypeString, Alias: Editor, Length: 120 )
Centennial_Tree (Type: esriFieldTypeString, Alias: Centennial_Tree, Length: 50 )
Honor_Category (Type: esriFieldTypeString, Alias: Honor_Category, Length: 25 )
Edit_Comments2009 (Type: esriFieldTypeString, Alias: Edit_Comments2009, Length: 80 )
ITIS_Hyperlink (Type: esriFieldTypeString, Alias: ITIS_Hyperlink, Length: 120 )
Photos_1 (Type: esriFieldTypeString, Alias: Photos_1, Length: 80 )
Shape (Type: esriFieldTypeGeometry, Alias: Shape)
Type ID Field: N/A

Relationships:
Campus.DBO.SpeciesDomain (0) -- Related To: Campus.DBO.SpeciesDomain (1)
Supported Interfaces:   REST

Supported Operations:   Query   Query Related Records
0 Kudos
JoeHershman
MVP Alum
For this definition


Relationships: 
Campus.DBO.SpeciesDomain (0) -- Related To: Campus.DBO.SpeciesDomain (1) 



The RelationshipId = 0.  The (1) after the second layer is the LayerId of the layer it is related to
Thanks,
-Joe
0 Kudos
JudyTroutwine
Regular Contributor
Thanks much Joe.  That does explain it.

Now please tell me how to vote and mark the response as you request.
0 Kudos
JoeHershman
MVP Alum
Thanks much Joe.  That does explain it.Now please tell me how to vote and mark the response as you request.
This explains the process  http://resources.arcgis.com/node/4617Thanks
Thanks,
-Joe
0 Kudos