<?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 Checking if a dataset name exists or not in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/checking-if-a-dataset-name-exists-or-not/m-p/1177340#M8196</link>
    <description>&lt;P&gt;I'd like to know if there is a simple function that will tell me if a dataset with a specific name exists or not.&lt;/P&gt;&lt;P&gt;Under ArcObjects we used to do this:&lt;/P&gt;&lt;P&gt;pWsSource2 = CType(pOutworkspace, IWorkspace2)&lt;BR /&gt;If pWsSource2.NameExists(esriDatasetType.esriDTFeatureClass, "whatever_the_name") Then&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;But with ArcGIS Pro SDK, I can only see a solution that does involve a loop like this:&lt;/P&gt;&lt;P&gt;var datasetDefinitions = geodatabaseMTNC.GetDefinitions&amp;lt;ArcGIS.Core.Data.FeatureDatasetDefinition&amp;gt;();&lt;/P&gt;&lt;P&gt;// Loop through the results&lt;BR /&gt;foreach (var definition in datasetDefinitions)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if(definition.GetName() == "whatever_the_name")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; // Do something&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there another approach?&lt;/P&gt;</description>
    <pubDate>Wed, 25 May 2022 19:29:19 GMT</pubDate>
    <dc:creator>MarioLandry2</dc:creator>
    <dc:date>2022-05-25T19:29:19Z</dc:date>
    <item>
      <title>Checking if a dataset name exists or not</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/checking-if-a-dataset-name-exists-or-not/m-p/1177340#M8196</link>
      <description>&lt;P&gt;I'd like to know if there is a simple function that will tell me if a dataset with a specific name exists or not.&lt;/P&gt;&lt;P&gt;Under ArcObjects we used to do this:&lt;/P&gt;&lt;P&gt;pWsSource2 = CType(pOutworkspace, IWorkspace2)&lt;BR /&gt;If pWsSource2.NameExists(esriDatasetType.esriDTFeatureClass, "whatever_the_name") Then&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;But with ArcGIS Pro SDK, I can only see a solution that does involve a loop like this:&lt;/P&gt;&lt;P&gt;var datasetDefinitions = geodatabaseMTNC.GetDefinitions&amp;lt;ArcGIS.Core.Data.FeatureDatasetDefinition&amp;gt;();&lt;/P&gt;&lt;P&gt;// Loop through the results&lt;BR /&gt;foreach (var definition in datasetDefinitions)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if(definition.GetName() == "whatever_the_name")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; // Do something&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there another approach?&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 19:29:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/checking-if-a-dataset-name-exists-or-not/m-p/1177340#M8196</guid>
      <dc:creator>MarioLandry2</dc:creator>
      <dc:date>2022-05-25T19:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: Checking if a dataset name exists or not</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/checking-if-a-dataset-name-exists-or-not/m-p/1177349#M8197</link>
      <description>&lt;P&gt;I call the geodatabase.GetDefinition () method.&amp;nbsp; This method must be called from a QueuedTask.Run.&amp;nbsp; GetDefinition throws an exception if the definition doesn't exist.&amp;nbsp;If there is another way to determine if a FeatureClass or Table exist, I hope someone will share it.&lt;/P&gt;&lt;P&gt;Here is the code that can be called from a QueuedTask:&lt;/P&gt;&lt;P&gt;public static bool FeatureClassExists(Geodatabase geodatabase, string featureClassName)&lt;BR /&gt;{&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;FeatureClassDefinition featureClassDefinition = geodatabase.GetDefinition&amp;lt;FeatureClassDefinition&amp;gt;(featureClassName);&lt;BR /&gt;featureClassDefinition.Dispose();&amp;nbsp; // FeatureClass found, dispose of object&lt;BR /&gt;return true;&lt;BR /&gt;}&lt;BR /&gt;catch&lt;BR /&gt;{&lt;BR /&gt;// GetDefinition throws an exception if the definition doesn't exist&lt;BR /&gt;return false;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;If you're checking for a Table, replace FeatureClassDefinition with TableDefinition:&lt;/P&gt;&lt;P&gt;TableDefinition tableDefinition = geodatabase.GetDefinition&amp;lt;TableDefinition&amp;gt;(tableName);&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 20:06:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/checking-if-a-dataset-name-exists-or-not/m-p/1177349#M8197</guid>
      <dc:creator>ChrisSeabrooke1</dc:creator>
      <dc:date>2022-05-25T20:06:37Z</dc:date>
    </item>
  </channel>
</rss>

