I don't see how those can be used in this case, however. Consider the Tops table for example (http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/2). It has no geometry directly associated with it, and if you try to query it with a spatial filter you get an error. It's spatial information is actually obtained by performing a related query on the Wells layer, providing the object ids for the Tops that you are interested in.As a more concrete example, say that I want to find all of the Tops locations where FORMATION = 'Heebner Shale Member', but I'm only interested in an area bounded by -75, 0, 0, 30 (spatial reference 4267). This is just an arbitrary boundary within the full extent of the Wells layer, but in real life users are often only interested in areas that are a subset of the full extent of a layer. How can I go about this?Relating to the first two methods I described above, here are the solutions (and problems) that I see.Method 1:Start by querying Tops...Query query = new Query() { Where = "FORMATION = 'Heebner Shale Member'" };Now I have a bunch of results with no geometry because the table has no geometry. That's fine, it's a related table, I can get the geometry from a relationship query. The problem is that in the relationship query, while I can get results with geometry, I can't apply a spatial filter as part of the relationship query.In the QueryTask_ExecuteCompleted for my Tops query, I can do:RelationshipParameter relationshipParameter = new RelationshipParameter() {
ObjectIds = (List<int>)e.FeatureSet.ObjectIDs,
RelationshipId = 3,
OutFields = new String[] { "*" }
};but now I still have results from the full extent of the Wells layer, rather than the spatial boundary that I am interested in, and in the Silverlight API I don't know of a good way to perform the filter from this point. Note that if there are multiple related layers, a separate relationship query must be performed for each. This takes a total of 1 + n queries, where n is the number of layers related to the table of interest.Method 2:Start by querying Wells... (in my real life example this means a separate query for each layer related to the table of interest).Query query = new Query() {
Geometry = spatialFilter // user specified boundary
ReturnGeometry = true
};
query.OutFields.Add("OBJECTID");Now I have all of the Well features within the boundary, but the user doesn't really care about this. They want to know the locations where Tops FORMATION = 'Heebner Shale Member', so I do a related query against wells (and again in real life this involved a separate query for each related layer). So, for each layer I do:RelationshipParameter relationshipParameter = new RelationshipParameter() {
ObjectIds = (List<int>)e.FeatureSet.ObjectIDs,
RelationshipId = 3,
DefinitionExpression = "FORMATION = 'Heebner Shale Member'",
OutFields = new String[] { "*" }
};As a result I now get a RelatedRecordsGroup which is of type IDictionary<int,IEnumerable<Graphic>>, but since none of these graphics have geometry I have to iterate through each of them and set their geometry based on the results of the original query.The total number of queries that it takes to perform this search is 2*n where n is the number of layers related to the table of interest.In both cases I'm also wasting resources by returning geometry for features that I don't care about. In Method 1 I'm returning geometry for only those features with Tops FORMATION = 'Heebner Shale Member' but those features are for the entire extent of the layer rather than the smaller extent of interest. In Method 2 I'm returning geometry for only those features in the extent of interest, but I will still end up discarding all of them except where Tops FORMATION = 'Heebner Shale Member'.If a RelationshipParameter was able to take a spatial filter then I could apply Method 1 while still making relatively efficient use of resources.Going back to the problem with method 1, where the results I am given span the entire extent since I can't specify Geometry for a RelationshipParameter, how can I go about applying a spatial filter to those results?