<?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: QueryTable Error in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/querytable-error/m-p/1125139#M7469</link>
    <description>&lt;P&gt;Thanks Wolf! I did add the dictionary declaration, but I didn't declare the value, mukey as a List.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed my dictionary declaration from "var MUResults = new Dictionary&amp;lt;string, &amp;lt;string&amp;gt;&amp;gt;();" to "var MUResults = new Dictionary&amp;lt;string, List&amp;lt;string&amp;gt;&amp;gt;();"&lt;/P&gt;&lt;P&gt;Once I changed the mukey declaration, I have the following error "cannot convert from string to System.Collection.Generic.List&amp;lt;string&amp;gt;." How can I resolve this error?&amp;nbsp; Thanks for your help!&lt;/P&gt;</description>
    <pubDate>Sat, 11 Dec 2021 01:48:17 GMT</pubDate>
    <dc:creator>ThiPham12</dc:creator>
    <dc:date>2021-12-11T01:48:17Z</dc:date>
    <item>
      <title>QueryTable Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/querytable-error/m-p/1123692#M7439</link>
      <description>&lt;P&gt;I am trying to use query table to create a list of strings, mukey, associated with specific counties, to use for further geoprocessing with other tables in the same geodatabase. I created a dictionary with the county as the key and mukey as the value to query the list of mukeys. However, I have an error: CS1061 at&amp;nbsp;&amp;nbsp; "MUResults[county].Add(mukey)" saying there is no accessible extension method to Add. I am wondering what I can do to resolve this problem? Here is my script below:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using (Geodatabase geodatabase = new Geodatabase(connection))&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp;QueryDef queryDef = new QueryDef&lt;BR /&gt;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Tables = "MUPOLYGON.Name",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; SubFields = "MUPOLYGON.OBJECTID, MUPOLYGON.AREASYMBOL, MUPOLYGON.MUSYM,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MUPOLYGON.MUKEY",&lt;BR /&gt;&amp;nbsp; &amp;nbsp; };&lt;/P&gt;&lt;P&gt;QueryTableDescription queryTableDescription = new QueryTableDescription(queryDef)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; Name = "MUTable",&lt;BR /&gt;&amp;nbsp; PrimaryKeys = geodatabase.GetSQLSyntax().QualifyColumnName("OBJECTID", "AREASYMBOL"),&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;Table queryTable = geodatabase.OpenQueryTable(queryTableDescription);&lt;/P&gt;&lt;P&gt;using (RowCursor rowCursor = queryTable.Search())&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; while (rowCursor.MoveNext())&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; using (var row = rowCursor.Current)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var county = Convert.ToString(row["AREASYMBOL"]);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var mukey = Convert.ToString(row["MUKEY"]);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (MUResults.ContainsKey(county))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; MUResults[county].Add(mukey);&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 03:17:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/querytable-error/m-p/1123692#M7439</guid>
      <dc:creator>ThiPham12</dc:creator>
      <dc:date>2021-12-08T03:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: QueryTable Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/querytable-error/m-p/1123703#M7441</link>
      <description>&lt;P&gt;There is no declaration of MUResults. But as I understand from your code, your last code line must be like that:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;MUResults[county]= mukey;
// or
MUResults.Add(county, mukey);
&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 08 Dec 2021 06:19:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/querytable-error/m-p/1123703#M7441</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2021-12-08T06:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: QueryTable Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/querytable-error/m-p/1123804#M7444</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/42133"&gt;@GKmieliauskas&lt;/a&gt;&amp;nbsp; mentioned you forgot to include the declaration for MUResults.&amp;nbsp; With the correct declaration your code can work:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var MUResults = new Dictionary&amp;lt;string, List&amp;lt;string&amp;gt;&amp;gt;();
MUResults.Add("County1", new List&amp;lt;string&amp;gt;() { "First Item for County 1" });
if (MUResults.ContainsKey("County1")) {
    MUResults["County1"].Add("Second Item for County 1"); 
}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 08 Dec 2021 14:37:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/querytable-error/m-p/1123804#M7444</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2021-12-08T14:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: QueryTable Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/querytable-error/m-p/1125139#M7469</link>
      <description>&lt;P&gt;Thanks Wolf! I did add the dictionary declaration, but I didn't declare the value, mukey as a List.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed my dictionary declaration from "var MUResults = new Dictionary&amp;lt;string, &amp;lt;string&amp;gt;&amp;gt;();" to "var MUResults = new Dictionary&amp;lt;string, List&amp;lt;string&amp;gt;&amp;gt;();"&lt;/P&gt;&lt;P&gt;Once I changed the mukey declaration, I have the following error "cannot convert from string to System.Collection.Generic.List&amp;lt;string&amp;gt;." How can I resolve this error?&amp;nbsp; Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Sat, 11 Dec 2021 01:48:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/querytable-error/m-p/1125139#M7469</guid>
      <dc:creator>ThiPham12</dc:creator>
      <dc:date>2021-12-11T01:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: QueryTable Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/querytable-error/m-p/1134229#M7619</link>
      <description>&lt;P&gt;Seem like the mukey is a string and not a list as declared in the dictionary.&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/507711"&gt;@ThiPham12&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Thanks Wolf! I did add the dictionary declaration, but I didn't declare the value, mukey as a List.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed my dictionary declaration from "var MUResults = new Dictionary&amp;lt;string, &amp;lt;string&amp;gt;&amp;gt;();" to "var MUResults = new Dictionary&amp;lt;string, List&amp;lt;string&amp;gt;&amp;gt;();"&lt;/P&gt;&lt;P&gt;Once I changed the mukey declaration, I have the following error "cannot convert from string to System.Collection.Generic.List&amp;lt;string&amp;gt;." How can I resolve this error?&amp;nbsp; Thanks for your help!&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var mukey = Convert.ToString(row["MUKEY"]);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you have to know if the content in mukey column is a string or you want to have a list of item (so a list of string). I think just change the dictionary to new Dictionary&amp;lt;string, string&amp;gt; should be fine.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Jan 2022 11:37:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/querytable-error/m-p/1134229#M7619</guid>
      <dc:creator>KennyPham</dc:creator>
      <dc:date>2022-01-16T11:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: QueryTable Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/querytable-error/m-p/1137591#M7689</link>
      <description>&lt;P&gt;I used the community sample data for my code below, specifically the data in&amp;nbsp;C:\Data\Admin\AdminData.gdb.&amp;nbsp; Needless to say, i had to change the table names and field names.&amp;nbsp; Here is the code for my sample button 'OnClick':&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;protected override async void OnClick()
{
  try
  {
    var MUResults = new Dictionary&amp;lt;string, List&amp;lt;string&amp;gt;&amp;gt;();
    var gdbFolder = @"C:\Data\Admin\AdminData.gdb";
    var gdbPath = new FileGeodatabaseConnectionPath(new Uri(gdbFolder));
    await QueuedTask.Run(() =&amp;gt;
    {
      using (Geodatabase geodatabase = new Geodatabase(gdbPath))
      {
        QueryDef queryDef = new QueryDef
        {
          Tables = "PopulationByCounty",
          SubFields = "OBJECTID, NAME, POP"
        };

        QueryTableDescription queryTableDescription = new QueryTableDescription(queryDef)
        {
          Name = "PopulationByCounty",
          PrimaryKeys = geodatabase.GetSQLSyntax().QualifyColumnName("PopulationByCounty", "NAME")
        };

        Table queryTable = geodatabase.OpenQueryTable(queryTableDescription);
        using (RowCursor rowCursor = queryTable.Search())
        {
          while (rowCursor.MoveNext())
          {
            using (var row = rowCursor.Current)
            {
              var county = row["NAME"].ToString();
              var mukey = row["POP"].ToString();
              if (MUResults.ContainsKey(county))
                MUResults[county].Add(mukey);
              else
                MUResults.Add(county, new List&amp;lt;string&amp;gt;() { mukey });
            }
          }
        }
      }
    });
    foreach (var county in MUResults.Keys)
    {
      System.Diagnostics.Trace.WriteLine($@"County: {county}");
      foreach (var mukey in MUResults[county])
      {
        System.Diagnostics.Trace.WriteLine($@" MUKEY - {mukey}");
      }
    }
  }
  catch (Exception ex)
  {
    MessageBox.Show(ex.Message);
  }
}&lt;/LI-CODE&gt;&lt;P&gt;And here some of the content (as output by my sample) for the dictionary:&lt;/P&gt;&lt;P&gt;County: Autauga County, Alabama&lt;BR /&gt;&amp;nbsp;MUKEY - 54597&lt;BR /&gt;&amp;nbsp;MUKEY - 54773&lt;BR /&gt;&amp;nbsp;MUKEY - 54893&lt;BR /&gt;&amp;nbsp;MUKEY - 55869&lt;BR /&gt;County: Baldwin County, Alabama&lt;BR /&gt;&amp;nbsp;MUKEY - 182265&lt;BR /&gt;&amp;nbsp;MUKEY - 183112&lt;BR /&gt;&amp;nbsp;MUKEY - 199183&lt;BR /&gt;&amp;nbsp;MUKEY - 223234&lt;BR /&gt;County: Barbour County, Alabama&lt;BR /&gt;&amp;nbsp;MUKEY - 27455&lt;BR /&gt;&amp;nbsp;MUKEY - 27327&lt;BR /&gt;&amp;nbsp;MUKEY - 26755&lt;BR /&gt;&amp;nbsp;MUKEY - 24686&lt;BR /&gt;County: Bibb County, Alabama&lt;BR /&gt;&amp;nbsp;MUKEY - 22915&lt;BR /&gt;&amp;nbsp;MUKEY - 22870&lt;BR /&gt;&amp;nbsp;MUKEY - 22553&lt;BR /&gt;&amp;nbsp;MUKEY - 22394&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 20:17:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/querytable-error/m-p/1137591#M7689</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2022-01-26T20:17:43Z</dc:date>
    </item>
  </channel>
</rss>

