Updating all attribute data in Feature Layer using ArcObjects

Discussion created by xupla on Feb 17, 2018
Latest reply on Feb 20, 2018 by gkmieliauskas_cellexp

I have a layer with over 250,000+ features, and I want to update all the attribute data using ArcObjects and C#. I have written the code below and it takes around 3 hours to perform the update. Can you suggest whether the code below is efficient enough and any suggestion regarding the delta tables please?


 public void updateWithCursor(IWorkspace workspace, IFeatureClass featureClass, List<Update> updateList)
            using (ComReleaser comReleaser = new ComReleaser())
                IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

                // Start an edit session

                // Start an edit operation
                // Use IFeatureClass.Search to create a search cursor.
                IFeatureCursor searchCursor = featureClass.Search(null, false);

                // Find the positions of the fields used to get and set values.
                int idIndex = featureClass.FindField("ID");
                int serialIndex = featureClass.FindField("SERIAL");
                int cityIndex = featureClass.FindField("CITY");
                int updateDateIndex = featureClass.FindField("UPDATEDATE");
                int counter = 0;
                IFeature feature = null;
                while ((feature = searchCursor.NextFeature()) != null)
                    string searchValue = feature.get_Value(idIndex).ToString();

                    if (searchValue != "")
                        Update upd = updateList.SingleOrDefault(x => x.id == searchValue);

                        if (upd != null)
                            feature.set_Value(serialIndex , upd.serialNo);
                            feature.set_Value(cityIndex , upd.city);
                            feature.set_Value(updateDateIndex, DateTime.Now);


                // Stop the edit session. The saveEdits parameter indicates the edit session
                // will be committed.