<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Adding/Editing Definition Query on ImageServiceLayer silently fails in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/adding-editing-definition-query-on/m-p/1488323#M11636</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/682709"&gt;@FanisDeligiannis&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can post back to this thread if I have an update on this issue. But here is a workaround to access and set queries. You can access the CIM Definition of the ImageService Layer - this will give you access to the definition queries. Here is a code snippet that shows you how to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        var definition  = imageServiceLayer.GetDefinition() as CIMImageServiceLayer;
        var featureTable = definition.FeatureTable;
        //This is a list of all the definition queries
        var defnFilterChoices = featureTable.DefinitionFilterChoices; 
        //Iterate through the definition queries
        foreach (var defnFilterChoice in defnFilterChoices)
        {
         //access the definition queries here
         var cimDefinitionFilter = defnFilterChoice as CIMDefinitionFilter;
          var queryName = cimDefinitionFilter.Name;
          var expression = cimDefinitionFilter.DefinitionExpression;
        }
        //To activate a definition query
        featureTable.DefinitionExpression = "Name = '76264301'"; //example
        featureTable.DefinitionExpressionName = "Query 1"; //example

        //Set defintion
        imageServiceLayer.SetDefinition(definition);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Jun 2024 15:59:04 GMT</pubDate>
    <dc:creator>UmaHarano</dc:creator>
    <dc:date>2024-06-10T15:59:04Z</dc:date>
    <item>
      <title>Adding/Editing Definition Query on ImageServiceLayer silently fails</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/adding-editing-definition-query-on/m-p/1486080#M11621</link>
      <description>&lt;P&gt;Hello. I am loading an ImageServiceLayer from a URL. Through the UI, I can add a Definition Query to it.&lt;/P&gt;&lt;P&gt;Through the SDK, I can see the previously created Definition Query. But I cannot add, edit or remove it in any way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;ImageServiceLayer ISL = null;

List&amp;lt;Layer&amp;gt; layers = map.GetLayersAsFlattenedList().ToList();
foreach (var layer in layers)
{
    if (layer is ImageServiceLayer)
    {
        if (layer.Name == "ImageLayer")
            ISL = layer as ImageServiceLayer;
    }
}

if (ISL == null)
{
    Uri uri = new Uri("...");
    ISL = LayerFactory.Instance.CreateLayer(uri, map, 0) as ImageServiceLayer;
}

// If I have set a Definition Query through ArcGIS Pro UI, I can read it using ISL.DefinitionQuery

DefinitionQuery dq = new DefinitionQuery("QueryName", "OBJECTID = 5");
ISL.InsertDefinitionQuery(dq, true); // This does nothing.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried a bunch of stuff but nothing seems to work. I can't edit an existing Definition Query, I can't remove it, I can't add a new one. Am I doing something wrong, or is it bugged?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2024 11:23:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/adding-editing-definition-query-on/m-p/1486080#M11621</guid>
      <dc:creator>FanisDeligiannis</dc:creator>
      <dc:date>2024-06-07T11:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: Adding/Editing Definition Query on ImageServiceLayer silently fails</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/adding-editing-definition-query-on/m-p/1487535#M11630</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I see the same issue. Thanks for reporting this one. I have submitted an issue to the development team that owns this functionality.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Uma&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2024 01:21:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/adding-editing-definition-query-on/m-p/1487535#M11630</guid>
      <dc:creator>UmaHarano</dc:creator>
      <dc:date>2024-06-08T01:21:34Z</dc:date>
    </item>
    <item>
      <title>Re: Adding/Editing Definition Query on ImageServiceLayer silently fails</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/adding-editing-definition-query-on/m-p/1488235#M11635</link>
      <description>&lt;P&gt;Will this be fixed in the next version?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2024 13:40:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/adding-editing-definition-query-on/m-p/1488235#M11635</guid>
      <dc:creator>FanisDeligiannis</dc:creator>
      <dc:date>2024-06-10T13:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: Adding/Editing Definition Query on ImageServiceLayer silently fails</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/adding-editing-definition-query-on/m-p/1488323#M11636</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/682709"&gt;@FanisDeligiannis&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can post back to this thread if I have an update on this issue. But here is a workaround to access and set queries. You can access the CIM Definition of the ImageService Layer - this will give you access to the definition queries. Here is a code snippet that shows you how to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        var definition  = imageServiceLayer.GetDefinition() as CIMImageServiceLayer;
        var featureTable = definition.FeatureTable;
        //This is a list of all the definition queries
        var defnFilterChoices = featureTable.DefinitionFilterChoices; 
        //Iterate through the definition queries
        foreach (var defnFilterChoice in defnFilterChoices)
        {
         //access the definition queries here
         var cimDefinitionFilter = defnFilterChoice as CIMDefinitionFilter;
          var queryName = cimDefinitionFilter.Name;
          var expression = cimDefinitionFilter.DefinitionExpression;
        }
        //To activate a definition query
        featureTable.DefinitionExpression = "Name = '76264301'"; //example
        featureTable.DefinitionExpressionName = "Query 1"; //example

        //Set defintion
        imageServiceLayer.SetDefinition(definition);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2024 15:59:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/adding-editing-definition-query-on/m-p/1488323#M11636</guid>
      <dc:creator>UmaHarano</dc:creator>
      <dc:date>2024-06-10T15:59:04Z</dc:date>
    </item>
  </channel>
</rss>

