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.
Solved! Go to Solution.
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
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
Thank you Sean! I knew it was something simple that I was missing. I really appreciate your time and effort.