Create Table Dataset from results of Portal Search and subitems

297
1
02-09-2022 02:04 PM
MKa
by
Occasional Contributor III

I am trying to query tables from a PortalItemType.FeatureService query.  I am using Pro sdk 2.5 so I cant use the ItemFactory.Instance.GetDataset when looping through my Feature Service tables.  So I think I need to somehow cast the Features Service to a geodatabase and get the dataset the old way with geodatabse.OpenDataset<Table>.  So my question is first, is there an easy way to cast my portal query feature service to a geodatabase, or to use ItemFactory.Instance.GetDataset(selectedItem) on my subitems of my Feature Service (i cant use method in my version of sdk)

 

PortalQueryParameters query = PortalQueryParameters.CreateForItemsOfTypes(new List<PortalItemType>() { PortalItemType.FeatureService }, "owner", "", "title:MyWebService");

                    //Loop until done
                    List<PortalItem> portalItems = new List<PortalItem>();

                    //run the search
                    PortalQueryResultSet<PortalItem> results = await portal.SearchForContentAsync(query);
                    portalItems.AddRange(results.Results);

                    if (!portalItems.IsNullOrEmpty())
                    {
                        string itemID = portalItems[0].ID;

//At this point i have my Feature Service (can i easily cast this to geodatabse??
                        Item currentFeatureService = ItemFactory.Instance.Create(itemID, ItemFactory.ItemType.PortalItem);

                        await QueuedTask.Run(() =>
                        {
//At this point i can loop through the tables to get the one I want
                            var subItems = currentFeatureService.GetItems();

                            foreach (var subItem in subItems)
                            {
                                if (subItem.Name == "DB.DBO.tableName")
                                {
                                    //How do i get the dataset at this point without using ItemFactory.Instance.GetDataset(selectedItem).  I am in Pro 2.5 right now and cant upgrade yet.
                                }
                            }

 

 

 

 

Tags (1)
0 Kudos
1 Reply
MKa
by
Occasional Contributor III

I cannot figure this part out from the wiki

If you are using ArcGIS Pro 2.8 or previous, then accessing the underlying dataset from the item requires a different pattern

  1. Access the path from the Item.Path property.
  2. Parse out the geodatabase connection path from the item path (this can be a path to a file gdb, sde file, or even folder).
  3. Instantiate the datasource pointed to by the connection path.
  4. Retrieve the dataset named in the Item.Name property from the datasource.
0 Kudos