Hi Community,
I am rewriting an ArcObjects SDK solution to ArcGIS Pro SDK CoreHost application.
The ArcObjects code queries the current locks on the table using ISchemaLock.GetCurrentSchemaLocks, and depends on whether the "SchemaLockType" is "esriExclusiveSchemaLock" or "esriSharedSchemaLock", it then uses the "IFeatureClassLoad.LoadOnlyMode" property to enable load-only mode on the target table.
What are the equivalent concepts and syntax in ArcGIS Pro SDK CoreHost?
Regards,
AB
In ArcGIS Pro SDK CoreHost, managing data access and concurrency differs significantly from ArcObjects. Unlike ArcObjects, where you could explicitly query schema locks using ISchemaLock.GetCurrentSchemaLocks, CoreHost abstracts lock management. The SDK assumes you have appropriate permissions and handles concurrency internally. If conflicts arise, operations like editing or schema modifications will throw exceptions, signaling lock or access issues.
Instead of directly working with schema locks or load-only modes, CoreHost provides tools like the EditOperation class to manage data edits in a transactional and efficient way. Below is an example of how you can manage edits, such as deleting features or rows, using the EditOperation class
await QueuedTask.Run(() =>
{
// Create an EditOperation to delete features
var deleteFeatures = new EditOperation() { Name = "Delete Features" };
// Access the first standalone table in the active map
var table = MapView.Active.Map.StandaloneTables.FirstOrDefault();
if (table == null)
{
throw new InvalidOperationException("No standalone tables found in the active map.");
}
// Specify the ObjectID of the row to delete
long oid = 1; // Replace with the actual ObjectID you want to delete
deleteFeatures.Delete(table, oid);
// Delete all selected features in the active view
// Create a polygon geometry for selection (example; replace with your geometry)
var polygon = GeometryEngine.Instance.Buffer(MapPointBuilder.CreateMapPoint(0, 0, SpatialReferences.WGS84), 10);
// Select features in the active view using the polygon
var selection = MapView.Active.SelectFeatures(polygon);
deleteFeatures.Delete(selection);
// Execute the EditOperation
if (!deleteFeatures.IsEmpty)
{
bool result = deleteFeatures.Execute(); // Returns true if the operation succeeds
if (!result)
{
throw new Exception("Delete operation failed.");
}
}
// Alternatively, use the async variant
// await deleteFeatures.ExecuteAsync();
});
Hi,
Thank you for the idea. However, my understanding is that CoreHost application cannot use EditOperation?
As stated in this community post Solved: Re: ArcGIS.Desktop.Core.Geoprocessing in standalon... - Esri Community, CoreHost applications don't have access to any of the ArcGIS.Desktop assemblies. EditOperations class is within Desktop Editing namespace.
Thanks,
Hi anbinh,
Could you please check below link
https://github.com/Esri/arcgis-pro-sdk/wiki/proconcepts-CoreHost
When the ArcGIS.Core API is used outside ArcGIS Pro (for example, in a console application) using the ArcGIS.CoreHost API support, it is referred to as stand-alone mode. In this mode, when performing edits in a transaction, the ArcGIS.Core.Data.Geodatabase.ApplyEdits method should be used.
Hi,
Are you suggesting that the AplpeEdits() kind of replace what SchemaLock was doing in ArcObjects?
Thanks,
Hi,
It depends if you want to apply lock for editing.
Could you please clarify why you were applying Schema locks in ArcObjects?
yes
The closest equivalent in the Pro SDK is to do the following:
1. Use the DDL routines to remove indices from the table
2. Add data using an Insert Cursor
3. Use the DDL routines to re-add indices to the table
You could also use python/geoprocessing with the Append tool.
I hope this helps,
--Rich