Select to view content in your preferred language

What's equivalent of ISchemaLock and IFeatureClassLoad in Pro SDK?

225
7
3 weeks ago
anbinh
by
Frequent Contributor

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

0 Kudos
7 Replies
SumitMishra_016
Frequent Contributor

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();
});

 



0 Kudos
anbinh
by
Frequent Contributor

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 CommunityCoreHost applications don't have access to any of the ArcGIS.Desktop assemblies. EditOperations class is within Desktop Editing namespace. 

 

Thanks,

 

0 Kudos
SumitMishra_016
Frequent Contributor

Hi anbinh,
Could you please check below link
https://github.com/Esri/arcgis-pro-sdk/wiki/proconcepts-CoreHost

Editing in stand-alone mode

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.

anbinh
by
Frequent Contributor

Hi, 

Are you suggesting that the AplpeEdits() kind of replace what SchemaLock was doing in ArcObjects?

 

Thanks,

SumitMishra_016
Frequent Contributor

Hi,

It depends if you want to apply lock for editing.

Could you please clarify why you were applying Schema locks in ArcObjects?

0 Kudos
SumitMishra_016
Frequent Contributor

yes

0 Kudos
RichRuh
Esri Regular Contributor

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

0 Kudos