How do you create a list of the records?

258
0
09-01-2023 04:12 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
0 Replies