1

As shown in the image below, I need to fetch query mentioned within query section of a layer using ArcObjects in C#.

            IDocument doc = ArcMap.Application.Document;
            IMxDocument mxDoc = doc as IMxDocument;
            IMap map = mxDoc.FocusMap;
            ILayer mapLayer = map.get_Layer(0);
            IFeatureClass c = (mapLayer as IFeatureLayer).FeatureClass;

enter image description here

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
jay
  • 141
  • 9

1 Answers1

6

Cast the layer to an IDatalayer2. Cast IDataLayer2.DataSourceName to IQueryTableName Get the SQL from IQueryTableName.Query

Kirk Kuykendall
  • 25,787
  • 8
  • 65
  • 153
  • Thanks bro. It worked like a charm. Did you check the answer i posted for a question that we were trying to solve. [link]https://gis.stackexchange.com/questions/286127/add-in-button-click-open-arccatalog-window-with-list-of-sde-files?noredirect=1#comment458807_286127 – jay Jun 18 '18 at 17:50