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

  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Mapperz
    Commented Jun 18, 2018 at 21:42

1 Answer 1


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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.