<?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: How to &amp;quot;Define parameters in a query layer&amp;quot; on a feature class? in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-quot-define-parameters-in-a-query-layer/m-p/1504116#M11854</link>
    <description>&lt;P&gt;Have you looked into the&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/3.2/sdk/api-reference/topic7517.html" target="_blank" rel="noopener"&gt;QueryDescription Class,&amp;nbsp;&lt;/A&gt;which is used to create&amp;nbsp;a table or feature class representing a &lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Geodatabase#query-layers" target="_self"&gt;query layer?&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Sample &lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets-Geodatabase#create-querydescription-from-a-custom-query-for-a-database-table" target="_self"&gt;code snippets&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jul 2024 13:18:16 GMT</pubDate>
    <dc:creator>Aashis</dc:creator>
    <dc:date>2024-07-11T13:18:16Z</dc:date>
    <item>
      <title>How to "Define parameters in a query layer" on a feature class?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-quot-define-parameters-in-a-query-layer/m-p/1504077#M11853</link>
      <description>&lt;P&gt;I'd like to incorporate this manual workflow into my dockpane,&amp;nbsp; but I don't find any useful documentation or samples. Does anyone know if it is possible and if yes, how it can be done?&lt;/P&gt;&lt;P&gt;my manual workflow:&lt;/P&gt;&lt;P&gt;I open an enterprise geodatabase feature class in a map in ArcGIS Pro. Then I open layer properties and go to source. there is the field "Query" (not definition query!) containing something like this "select attribute 1, attribute 2, ..., attribute n FROM layername".&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nadja_swiss_parks_0-1720700834509.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/109457i6D6A5468BF9E91D7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="nadja_swiss_parks_0-1720700834509.png" alt="nadja_swiss_parks_0-1720700834509.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I then click on the pen on the right hand side and modify the query to "select * from layername".&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found this documentation:&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/mapping/layer-properties/define-parameters-in-a-query-layer.htm" target="_blank" rel="noopener"&gt;https://pro.arcgis.com/en/pro-app/latest/help/mapping/layer-properties/define-parameters-in-a-query-layer.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;but I'm trying to do it in a dockpane for any layer that i add to my map using this method:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri(sde_path))))
{

    //ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(featureClassDefinition.ToString(), "featureClassDefinition");
    using (FeatureClass fc = geodatabase.OpenDataset&amp;lt;FeatureClass&amp;gt;("parcs." + name))
    {
        // Create the feature layer creation parameters
        FeatureLayerCreationParams layerCreationParams = new FeatureLayerCreationParams(fc)
        {
            // Optionally set additional properties
            Name = name
        };


        // Create the feature layer and add it to the active map
        await QueuedTask.Run(() =&amp;gt; LayerFactory.Instance.CreateLayer&amp;lt;FeatureLayer&amp;gt;(layerCreationParams, MapView.Active.Map));
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how can i add the layer such that its query says "select * from layername"? any help is greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 12:31:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-quot-define-parameters-in-a-query-layer/m-p/1504077#M11853</guid>
      <dc:creator>nadja</dc:creator>
      <dc:date>2024-07-11T12:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to "Define parameters in a query layer" on a feature class?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-quot-define-parameters-in-a-query-layer/m-p/1504116#M11854</link>
      <description>&lt;P&gt;Have you looked into the&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/3.2/sdk/api-reference/topic7517.html" target="_blank" rel="noopener"&gt;QueryDescription Class,&amp;nbsp;&lt;/A&gt;which is used to create&amp;nbsp;a table or feature class representing a &lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Geodatabase#query-layers" target="_self"&gt;query layer?&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Sample &lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets-Geodatabase#create-querydescription-from-a-custom-query-for-a-database-table" target="_self"&gt;code snippets&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 13:18:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-quot-define-parameters-in-a-query-layer/m-p/1504116#M11854</guid>
      <dc:creator>Aashis</dc:creator>
      <dc:date>2024-07-11T13:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to "Define parameters in a query layer" on a feature class?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-quot-define-parameters-in-a-query-layer/m-p/1504151#M11855</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You can create layer with geoprocessing tool&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/make-query-layer.htm" target="_self"&gt;Make Query Layer&lt;/A&gt;. It&amp;nbsp;&lt;SPAN&gt;creates a query layer from a DBMS table based on an input SQL select statement. So, you don't need your code above. How to call geoprocessing tool you can find &lt;A href="https://pro.arcgis.com/en/pro-app/3.2/sdk/api-reference/topic9384.html" target="_self"&gt;here&lt;/A&gt;. Tool name for calling would be "management.MakeQueryLayer"&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 14:09:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-quot-define-parameters-in-a-query-layer/m-p/1504151#M11855</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2024-07-11T14:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to "Define parameters in a query layer" on a feature class?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-quot-define-parameters-in-a-query-layer/m-p/1504403#M11858</link>
      <description>&lt;P&gt;In line 16 when you have the layer it is pretty simple:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var queryName = "My Special Query";
var whereClause = "1 = 1";
layer.InsertDefinitionQuery(new DefinitionQuery(queryName, whereClause), true);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since you are creating a new layer you don't have to check if the query already exist but that is also quite simple.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var q = layer.DefinitionQueries.SingleOrDefault(e =&amp;gt; e.Name.Equals(queryName, StringComparison.CurrentCultureIgnoreCase));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Complete:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// Create the feature layer and add it to the active map
await QueuedTask.Run(() =&amp;gt; {
    var layer = LayerFactory.Instance.CreateLayer&amp;lt;FeatureLayer&amp;gt;(layerCreationParams, MapView.Active.Map)

    var queryName = "My Special Query";
    var whereClause = "1 = 1";
    layer.InsertDefinitionQuery(new DefinitionQuery(queryName, whereClause), true);
});&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 11 Jul 2024 18:58:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-quot-define-parameters-in-a-query-layer/m-p/1504403#M11858</guid>
      <dc:creator>pocalipse</dc:creator>
      <dc:date>2024-07-11T18:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to "Define parameters in a query layer" on a feature class?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-quot-define-parameters-in-a-query-layer/m-p/1505276#M11872</link>
      <description>&lt;P&gt;Thank you, that code snippet works, but unfortunately it creates a definition query, whereas I meant the query under layer properties &amp;gt;&amp;gt; source &amp;gt;&amp;gt; query...&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2024 08:48:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-quot-define-parameters-in-a-query-layer/m-p/1505276#M11872</guid>
      <dc:creator>nadja</dc:creator>
      <dc:date>2024-07-15T08:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to "Define parameters in a query layer" on a feature class?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-quot-define-parameters-in-a-query-layer/m-p/1505948#M11880</link>
      <description>&lt;P&gt;Here is a code snippet that creates a Query Layer - with the "SqlQuery" defined.&amp;nbsp; &lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets-MapAuthoring#create-a-query-layer" target="_self"&gt;Create a query layer&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;await QueuedTask.Run(() =&amp;gt;
{
  Map map = MapView.Active.Map;
  Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri(@"C:\Connections\mySDE.sde")));
  CIMSqlQueryDataConnection sqldc = new CIMSqlQueryDataConnection()
  {
    WorkspaceConnectionString = geodatabase.GetConnectionString(),
    GeometryType = esriGeometryType.esriGeometryPolygon,
    OIDFields = "OBJECTID",
    Srid = "102008",
    SqlQuery = "select * from MySDE.dbo.STATES",
    Dataset = "States"
  };
  var lcp = new LayerCreationParams(sqldc)
  {
    Name = "States"
  };
  FeatureLayer flyr = LayerFactory.Instance.CreateLayer&amp;lt;FeatureLayer&amp;gt;(lcp, map);
});&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 16 Jul 2024 20:41:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-quot-define-parameters-in-a-query-layer/m-p/1505948#M11880</guid>
      <dc:creator>UmaHarano</dc:creator>
      <dc:date>2024-07-16T20:41:19Z</dc:date>
    </item>
  </channel>
</rss>

