How can I get the database for a layer based on the CIMFeatureDatasetDataConnection (GetDataConnection)?

2484
2
08-16-2015 10:11 AM
Highlighted
New Contributor III

Hi there,

I was wondering if it's possible to get the actual geodatabase through the BasicFeatureLayer.GetDataConnection() method, which (can) return a CIMFeatureDatasetDataConnection.

I found, that when working with a filegdb, I can get the path for the fgdb. The path I can use in return to create a new Geodatabase object. If I try to do the same with an enterprise gdb, I can retrieve only the connection string. Even though I can use the connection string to create a new ConnectionProperies object, the object can not be used to open a Geodatabase. If I try this, I can some type of time-out.

I'm now wondering, if there's an easier way to get the underlying Geodatabase object for a feature layer.

thanks in advance,

Chris

Tags (1)
Reply
0 Kudos
2 Replies
Highlighted
Esri Contributor

Like so:

//assume that the first layer of the map is a FeatureLayer

            var featLayer = MapView.Active.Map.GetLayersAsFlattenedList()[0] as FeatureLayer;

            await QueuedTask.Run(() =>

            {

                var fc = ((FeatureLayer)featLayer).GetFeatureClass();

                var gdb = fc.GetDatastore() as Geodatabase;

                //Do something with the gdb

            });

Reply
0 Kudos
Highlighted
New Contributor III

Hi Charles,

thanks for the info. This was exactly what I was looking for.

Cheers, Chris

Reply
0 Kudos