EditOperation .Modify method is not working as expected. What am I missing here?

281
2
Jump to solution
07-16-2018 05:55 PM
Highlighted
New Contributor II

The following code sample should write the string "Test" to the "ROW_Notes" field for the first 200 object IDs of the Centerlines feature class. The code outputs the street's full name via the debugging console, so I know that I have a good database connection and the row cursor is functioning as expected. Clearly I am missing something as the string "Test" is not written to the "ROW_Notes" field. When I run this sample, the Edit tab does not even register that an edit operation has taken place (i.e. the save and discard buttons remain grayed out.) Any thoughts as to what I am missing here?  Thanks for looking!

  

            await QueuedTask.Run(() =>
            {
                DatabaseConnectionProperties connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer){...}
                Geodatabase Landbase = new Geodatabase(connectionProperties);
                FeatureClass centerLines = Landbase.OpenDataset<FeatureClass>("Transportation.DBO.Cntlr_l");

                var qf = new QueryFilter() { WhereClause = "OBJECTID < 201" };
                var cursor = centerLines.Search(qf);
                var op = new EditOperation { Name = "Street Utility" };

                while (cursor.MoveNext())
                {
                    Row row = cursor.Current;
                    string fullName = row["FULLNAME"].ToString();
                    Debug.WriteLine(fullName);
                    op.Modify(row, "ROW_Notes", "Test");
                    //row.Store(); - Exception -
                }
                op.Execute();
            });‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

As a follow up question, anytime I try to use the row.Store() method, I get an exception stating : 'Objects in this object class cannot be updated outside of an edit session.' How does one properly implement the row.Store(); method? I am having difficulty finding an example of how that method is used in the snippets / examples. A brief example would be greatly appreciated.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Esri Regular Contributor

Stuart,

You'll need to use a non-recycling cursor when modifying rows. The search method defaults to a recycling cursor.

Row.Store isn't required in this case as Modify does all the legwork.

Row.Store is only really used when modifying rows with row objects.

For examples you can look at the edit and geodatabase concepts pages in the sdk help.

https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Editing

https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Geodatabase

https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-Geodatabase

View solution in original post

0 Kudos
2 Replies
Highlighted
Esri Regular Contributor

Stuart,

You'll need to use a non-recycling cursor when modifying rows. The search method defaults to a recycling cursor.

Row.Store isn't required in this case as Modify does all the legwork.

Row.Store is only really used when modifying rows with row objects.

For examples you can look at the edit and geodatabase concepts pages in the sdk help.

https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Editing

https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Geodatabase

https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-Geodatabase

View solution in original post

0 Kudos
Highlighted
New Contributor II

Thank you Sean! I knew it was something simple that I was missing. I really appreciate your time and effort.

0 Kudos