Select to view content in your preferred language

How do you create a list of the records using field definition?

473
2
09-01-2023 04:13 PM
tzz_12
by
New Contributor III

I wrote a method to create a list of a feature class' ID field, but it takes at least a minute to complete. I was wondering if it would possible to just to create a definition of the field and create a list from it? Please see the script I started to try to use the definition of the field to create the list and my original method. 

 

 

 

 Table table = featLayer.GetTable();
            using (TableDefinition tabledef = table.GetDefinition())
            {
                var fieldID = tabledef.GetFields().First(x => x.Name.Equals(fieldIDName));      
.
                foreach (var fieldID in fieldIDs) 
                {
                    FieldIDList.Add(fieldID.Name);
                }
            }
 public List<string> GetFieldIDs(FeatureLayer CopyLyr, string AggregateField)
        {
            var FieldIDs = new List<string>();

            using (var rowCursor = CopyLyr.Search())
            {
                while (rowCursor.MoveNext())
                {
                    using (Row row = rowCursor.Current)
                    {
                        string fieldID = Convert.ToString(row[AggregateField]);
                        FieldIDs.Add(fieldID);

                    }
                }
            }
            return FieldIDs;
        }

 

 

 

 

0 Kudos
2 Replies
remo053
New Contributor

So this happens automatically already. I guess the trouble you face is having the options in a different sheet. Just don't do it that way, keep all the options together, extra lines can be hidden via the group option on the right click pop up menu https://speedtest.vet/ .

If you need I can put together a model sheet with those methods

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

How many fields and records do you have in your table?

0 Kudos