how do i iterate through the rows of a feature service form portal?
i have a list of portal items as per this url
CreateForItemsOfType Method—ArcGIS Pro
i can iterate through and get the item name etc but how do i do the equivalent of a python searchCursor?
i just want to find a value in a field.
i have searched for hours, what am i missing?
Solved! Go to Solution.
solved
need to have the table name with the layer index of the table as a prefix, in my case it is Layer 1 so its prefixed with "L0", i.e
using (Table table = geodatabase.OpenDataset<Table>($"L0{pi.Name}"))
I have made some progress, now the issue is it throws the error that the table cant be found, yet i get the name from the item, i cant believe this is so difficult
foreach (var pi in portalItems)
{
    if (pi.Name == <TABLE_NAME>)
    {
        MessageBox.Show($"ITEM : {pi}");
        MessageBox.Show($"ITEM NAME : {pi.Name}");
        MessageBox.Show($"ITEM NAME : {pi.Path}");                  
      
        Uri uri = new Uri(pi.Path);
        ServiceConnectionProperties serviceConnectionProperties = new ServiceConnectionProperties(uri);
        using (Geodatabase geodatabase = new Geodatabase(serviceConnectionProperties))
        {
            using (Table table = geodatabase.OpenDataset<Table>(pi.Name))
            {                
                
                using (RowCursor rowCursor = table.Search(null,false))
                {
                    while (rowCursor.MoveNext())
                    {
                        using (Row row = rowCursor.Current)
                        {
                            string val = Convert.ToString(row["NAME"]);
                            MessageBox.Show(val);
                        }
                    }
                }
            }
        }
    }
}
solved
need to have the table name with the layer index of the table as a prefix, in my case it is Layer 1 so its prefixed with "L0", i.e
using (Table table = geodatabase.OpenDataset<Table>($"L0{pi.Name}"))
