<?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 get object id for the Query Layer in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-get-object-id-for-the-query-layer/m-p/1375094#M11040</link>
    <description>&lt;P&gt;I would recommend you to check selectedFeatureLayer for OID type field using code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var fieldDescriptions = selectedFeatureLayer.GetFieldDescriptions();
var oidField = fieldDescriptions.Find(x =&amp;gt; x.Type == FieldType.OID);
if(oidField != null)
{
    var oidName = oidField.Name;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Jan 2024 20:35:46 GMT</pubDate>
    <dc:creator>GKmieliauskas</dc:creator>
    <dc:date>2024-01-26T20:35:46Z</dc:date>
    <item>
      <title>How to get object id for the Query Layer</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-get-object-id-for-the-query-layer/m-p/1375069#M11039</link>
      <description>&lt;P&gt;Hello everyone, I am need of your assistance.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am unable to get object id for the Query Layer. I can get it for shapefile or sde feature class.&amp;nbsp;&lt;BR /&gt;Please take a look at the sample code below.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;BR /&gt;Trushar Mistry&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        //--------------------------------------------------
        // trusharm 2024-01-04 4:37pm, query layer GetDefinition() throws
        // exception so we are unable to get field names, hence we cannot
        // query layer at the moment until Esri fixes the issue
        [NotNull]
        private static string GetIdFieldForSpatialView([NotNull] FeatureLayer selectedFeatureLayer) =&amp;gt;
            ((CIMSqlQueryDataConnection)selectedFeatureLayer.GetDataConnection())
            .OIDFields
            .Contains("OBJECTID", StringComparison.InvariantCulture)
                ? "OBJECTID"
                : throw new InvalidOperationException("The view must at least have OBJECTID as unique index");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 19:42:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-get-object-id-for-the-query-layer/m-p/1375069#M11039</guid>
      <dc:creator>trushar</dc:creator>
      <dc:date>2024-01-26T19:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to get object id for the Query Layer</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-get-object-id-for-the-query-layer/m-p/1375094#M11040</link>
      <description>&lt;P&gt;I would recommend you to check selectedFeatureLayer for OID type field using code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var fieldDescriptions = selectedFeatureLayer.GetFieldDescriptions();
var oidField = fieldDescriptions.Find(x =&amp;gt; x.Type == FieldType.OID);
if(oidField != null)
{
    var oidName = oidField.Name;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 20:35:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-get-object-id-for-the-query-layer/m-p/1375094#M11040</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2024-01-26T20:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to get object id for the Query Layer</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-get-object-id-for-the-query-layer/m-p/1375498#M11043</link>
      <description>&lt;P&gt;Thank you for your example&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/42133"&gt;@GKmieliauskas&lt;/a&gt;!&lt;BR /&gt;&lt;BR /&gt;Apologies, I posted the question in rush and did not explain correctly nor did I copy the correct code sample.&lt;/P&gt;&lt;P&gt;Here is the core issue that I was attempting to get help on. I need access to column names and data under it so I can further bind it to my UI:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using var table = (selectedFeatureLayer.GetDataConnection() is CIMSqlQueryDataConnection { WorkspaceFactory: WorkspaceFactory.SDE })
                    ? selectedFeatureLayer.GetTable()
                    : throw new InvalidOperationException("...");

var field in table.GetDefinition().GetFields()&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;The `GetDefinition()` fails for me for layer type `CIMSqlQueryDataConnection`. The exception is coming from `ArcGIS.Core.Data.GetDefinitionHandle()`. Is it possible there is an alternate way to get field names for query layers, would you happen to know?&lt;BR /&gt;&lt;BR /&gt;Thank you again for your time,&lt;BR /&gt;Trushar M&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2024 16:59:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-get-object-id-for-the-query-layer/m-p/1375498#M11043</guid>
      <dc:creator>trushar</dc:creator>
      <dc:date>2024-01-29T16:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to get object id for the Query Layer</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-get-object-id-for-the-query-layer/m-p/1375982#M11045</link>
      <description>&lt;P&gt;Could you please specify more information about ArcGIS Pro version and database type? There are some issues with GetDefinition method in ArcGIS Pro 3.2 and PostgreSql database. More info &lt;A href="https://community.esri.com/t5/arcgis-pro-sdk-questions/arcgis-core-data-table-getdefinition-not-working/m-p/1365726" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 16:49:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-get-object-id-for-the-query-layer/m-p/1375982#M11045</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2024-01-30T16:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to get object id for the Query Layer</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-get-object-id-for-the-query-layer/m-p/1376750#M11053</link>
      <description>&lt;P&gt;Thank you for the link, I noticed&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-pro-sdk-questions/arcgis-core-data-table-getdefinition-not-working/m-p/1369396/highlight/true#M10998" target="_self"&gt;DaveFullerton&lt;/A&gt;&amp;nbsp;is running into same issue.&lt;BR /&gt;I am using ArcGIS Pro 3.2.1 and I am connected to SqlServer 2016.&lt;/P&gt;&lt;P&gt;Do I open a bug ticket with Esri?&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Trushar&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2024 21:10:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-get-object-id-for-the-query-layer/m-p/1376750#M11053</guid>
      <dc:creator>trushar</dc:creator>
      <dc:date>2024-01-31T21:10:17Z</dc:date>
    </item>
  </channel>
</rss>

