I have a WorkspaceConnectionString from CIMFeatureDatasetDataConnection looking like that:
With this ConnectionString I like to open a Enterprise Geodatabase (SDE):
GDB = new Geodatabase(new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer)
What is the best way to do this?
@Zoggo, The Pro SDK doesn’t have a method to open/connect the geodatabase from a workspace connection string. I am curious to know why you use CIMFeatureDatasetDataConnection. Can you use FeatureLayer.GetFeatureClass().GetDatastore() as Geodatabase instead?
I'm working with a linear referencing layer (Route Feature Layer). The event table is in a filegeodatabase and the route features is in a enterprise geodatabase. If I use FeatureLayer.GetFeatureClass().GetDatastore() as Geodatabase I only get the filegeodatabase workspace from the table but I need the enterprise geodatabase workspace from the route features.
@Zoggo , A workaround to access the route feature class’s geodatabase from route event layer
// Get all layers from the map IReadOnlyList<Layer> layers = MapView.Active.Map.GetLayersAsFlattenedList(); // Assuming route event layer is the first layer of map CIMRouteEventDataConnection connection = layers.GetDataConnection() as CIMRouteEventDataConnection; // Get connection to the route feature class CIMDataConnection routeFeatureClassConnection = connection.RouteFeatureClass ; // Create a feature layer using the route feature class connection FeatureLayer featureLayer = LayerFactory.Instance.CreateLayer(routeFeatureClassConnection, MapView.Active.Map, layerName: "RouteFeatureClass" ) as FeatureLayer; // Use feature layer to access the geodatabase Geodatabase geodatabase = featureLayer.GetFeatureClass().GetDatastore() as Geodatabase;
Basically it works. But the solution isn't nice. Because it adds the FeatureClass to the map. That's not wanted and very slow. Is there no other way without adding the layer to the map?