Select to view content in your preferred language

Relationships On a Tiled Layer In Silverlight API

936
1
01-14-2011 09:57 AM
JamesStreet1
Emerging Contributor
I know you can access the relationships from a feature layer via myLayer.LayerInfo.Relationships but is there a way to perform something similar for tiled and dynamic layers?

Seems like all the information is there but the LayerInfo class is missing the property.
0 Kudos
1 Reply
DominiqueBroux
Esri Frequent Contributor
The FeatureLayerInfo class is giving this info, so what you can do is to create a FeatureLayer by code (even without adding it the map, and get the needed info when the layer is initialized).

Example of code:

private void ArcGISDynamicMapServiceLayer_Initialized(object sender, System.EventArgs e)
{
    ArcGISDynamicMapServiceLayer dynamicLayer = sender as ArcGISDynamicMapServiceLayer;
    if (dynamicLayer != null)
    {
        FeatureLayer featureLayer = new FeatureLayer {Url = dynamicLayer.Url + "/0"};
        featureLayer.Initialized += featureLayer_Initialized;
        featureLayer.Initialize();
    }
}
 
void featureLayer_Initialized(object sender, System.EventArgs e)
{
    var featureLayer = sender as FeatureLayer;
 
    if (featureLayer != null && featureLayer.LayerInfo.Relationships != null)
    {
        foreach (var relationShip in featureLayer.LayerInfo.Relationships)
            Debug.WriteLine(string.Format("RelationShip ID={0} Name={1} RelatedTableId={2}", relationShip.Id, relationShip.Name,
                                            relationShip.RelatedTableId));
    }
}


Used with this map service (http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/MapServer), the result is :
RelationShip ID=1 Name=ServiceRequest_IncidentPriority RelatedTableId=1
0 Kudos