ArcGIS – How to Set a Definition Query for an AGS Layer

arcgis-10.0arcgis-enginearcgis-serverarcobjectsdevelopment

Is it possible to filter out some features using a definition query set from the client on a AGS layer?

I've checked out the map server layer but it only supports find and identify. Also looked at WMS, WFS and the Feature Service but I can't find a way that works. Do I need to extend the AGS to get this functionality?

Update:
What I'm trying to do is opening an MXD in an ArcGIS Engine application. The MXD has an ArcGIS Server map server layer. I would like to filter out some of the features in one of the ArcGIS Server layers by using a definition query.

Best Answer

I don't see an easy way to do this. But might be worth trying this:

Write a custom ILayer for arcgis that uses webclient to make a REST request that queries the mapservice layer. For the constructor pass the URL to the mapserverlayer, then insert the "rest" and append a where clause. Keep in mind REST urls are case sensitive. Using the returned JSON string, build an array of some POCO equivalent to IFeatures and loop through those when ILayer.Draw is called. It won't be fast, but WMS often isn't fast either.

If the service is running under 10.0 sp1, you should also be able to fetch any bitmaps used for rendering and make you own renderer in arcengine via IPictureMarkerSymbol.