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