1

I've been teaching myself ESRI ArcObjects in C# over the past few weeks, I'm still very new in the ArcObjects world.

All of our data is in an Enterprise geodatabase on a MS SQL Server database. I've been able to open the SDEWorkspace, iterate through said workspace datasets and eventually come to the feature class. I get the IFeatureCursor, iterate through that, find the IFeature object that I want to query via comparing the OID and then cast its IGeomertry Shape to IPoint, IArea whatever it is and pullout coodinants and fiddle with them.

I do have this problem where users will create new objects throughout that day but they will be inaccessable until they post and the database is compressed. I know how the versioning all works on a database level, but I don't know how to get that latest data out of the geodatabse before a post.

I can however find the SHAPE value ID within the version tables of the database, is there a fast way to just jump to a IGeometry Shape class if I know the Shape ID thats listened from within the database table.

For example I have a point feature class that has a SHAPE number of 9291884. Can I go straight to that somehow?

Alternatively, I can see the 'image' binary data stored in the points column in the database table, can I read that in and just cast it to an IPoint? Is that possible?

3
  • Working crosswise to the use case is supposed to be difficult. You need to specify the appropriate version in order to see edits before they are posted.
    – Vince
    Commented Jul 28, 2020 at 12:08
  • how do I change the version that i'm looking at?
    – megabytes
    Commented Jul 28, 2020 at 22:24
  • 1
    It's not something that I've tried but the IVersionedWorkspace resources.arcgis.com/en/help/arcobjects-net/componenthelp/… implemented by Sde4Workspace coclass sounds like what you're after provided your database is running SDE which was EOLed by Esri at 10.2, I've got absolutely no idea about direct connections without SDE, it is possible though that the SDE workspace objects will work with a direct connection for backward compatibility. I applaud your efforts of self learning ArcObjects, that's the way I did it, it's not easy. Commented Jul 29, 2020 at 2:33

1 Answer 1

1

Thanks @Michael Stimson, youre right the IVersionedWorkspace was the way to go. Here is the ending up code that I've run with.

    IVersionedWorkspace3 versionedWorkspace = (IVersionedWorkspace3)workspace;
    IEnumVersionInfo enumVersionInfo = versionedWorkspace.Versions;
    enumVersionInfo.Reset();

    IVersionInfo versionInfo = enumVersionInfo.Next();
    while (versionInfo != null)
    {
            string versionName = versionInfo.VersionName;
            cbxVersion.Add(versionName);
            Console.WriteLine("Version:  " + versionName);

            if (versionName == "UserVersionName")
            {
                Console.WriteLine("Found correct workspace");
                _versionFW = (IFeatureWorkspace)versionedWorkspace.FindVersion(versionName);
                break;
            }

            versionInfo = enumVersionInfo.Next();
        }

        IEnumDataset datasets = workspace.get_Datasets(esriDatasetType.esriDTFeatureDataset);
        IDataset dataset = null;
        while ((dataset = datasets.Next()) != null)
        {
            IFeatureClass featureClass = _versionFW.OpenFeatureClass(datasets.Name);
            ...
            ...
        }
    }
1
  • Excellent, +1 from me. It's a fairly obscure part of ArcObjects so it's great to have a working example. Commented Aug 10, 2020 at 6:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.