I am playing with the ArcGIS Pro SDK, and got stuck when trying to delete a feature from a featureclass using an EditOperation.
While FeatureClass.DeleteRows() works fine, the following code throws an error: No parameterless constructor defined for this object.
var result = await QueuedTask.Run(() =>
using (var gdb = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\Data\Test.gdb"))))
var fc = gdb.OpenDataset<FeatureClass>("punten");
var cursor = fc.Search(null, false);
var editOp = new EditOperation
Name = "Een test"
Also, modifying a feature works perfect:
editOp.Modify(cursor.Current, "test", "Hello");
Am I missing something?
As an aside, the FeatureClass, RowCursor, and Row classes all implement System.IDisposable. For correct object lifetime management, you should wrap usage of those variables in a using block. You may have simply removed that code to simplify the sample, but I wasn't sure. (This does not have any impact on the actual delete bug).
We're planning on clarifying this in the geodatabase conceptual documentation in the next release.
Yes, thanks for the reminder about disposing objects.
I was wondering, are Row and Feature objects meant to be short lived, or is it OK to keep them in memory? What are the best practices?
The best practice is definitely to call Dispose on Row and Feature objects. Keeping these objects around in memory can cause the system to hold onto file handles or database connections.