I'm trying to create a new Layer from a table which is the result of a join between a FeatureClass and a table. I used the following example as a basis (specifically the "MakeJoin"-Function from "JoinsDockPaneViewModel.cs"):
https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Geodatabase/DynamicJoins
The FeatureClass comes from a file geodatabase, the table from a postgreSQL database that is not an enterprise geodatabase. My code looks like this:
private RelationshipClass MakeJoin(RelationshipClass relationshipClass, Table leftTable, Table rightTable, Field leftField, Field rightField, string layername)
{
VirtualRelationshipClassDescription virtualRelationshipClassDescription = new VirtualRelationshipClassDescription(leftField, rightField, RelationshipCardinality.OneToOne);
relationshipClass = leftTable.RelateTo(rightTable, virtualRelationshipClassDescription);
JoinDescription joinDescription = new JoinDescription(relationshipClass)
{
JoinDirection = JoinDirection.Forward,
JoinType = JoinType.InnerJoin,
TargetFields = leftTable.GetDefinition().GetFields()
};
Join join = new Join(joinDescription);
Table joinedTable = join.GetJoinedTable();
if (joinedTable is FeatureClass)
{
FeatureClass joinedFc = (FeatureClass) joinedTable;
FeatureLayerCreationParams layerParams = new FeatureLayerCreationParams(joinedFc);
LayerFactory.Instance.CreateLayer<FeatureLayer>(layerParams, MapView.Active.Map);
}
return relationshipClass;
}
At line 19 (CreateLayer) the following Exception occurs:
A user-supplied component or subscriber raised an exception (0x80040208)
System.ArgumentException
Quelle: ArcGIS.Desktop.Mapping
TargetSite: T MakeBasicServiceCall[T](System.Func`1[T])
Stack:
at ArcGIS.Desktop.Internal.Mapping.Utilities.MakeBasicServiceCall[T](Func`1 serviceCall)
at ArcGIS.Desktop.Mapping.LayerCreationParams.CreateFromDataConnection(ILayerContainerEdit mapOrGroupLayer, Int32 index)
at ArcGIS.Desktop.Mapping.LayerCreationParams.CreateLayer(ILayerContainerEdit mapOrGroupLayer, Int32 layerIndex)
at ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer[T](LayerCreationParams layerParams, ILayerContainerEdit container)
InnerException:
A user-supplied component or subscriber raised an exception (0x80040208)
System.Runtime.InteropServices.COMException
Quelle: ArcGIS.Desktop.Mapping
TargetSite: System.String AddData(ArcGIS.Desktop.Internal.Mapping.CreateLayerArgs ByRef, System.String)
Stack:
at ArcGIS.Desktop.Internal.DesktopService._IMapAuthoringService.AddData(CreateLayerArgs& args, String dataConnectionXml)
at ArcGIS.Desktop.Mapping.Map.<>c__DisplayClass316_0.<AddData>b__0()
at ArcGIS.Desktop.Internal.Mapping.Utilities.MakeBasicServiceCall[T](Func`1 serviceCall)
The exception doesn't occur when I use two FeatureClasses to create the join. The only workaround for this is the use of the Geoprocessing tool.
I have already posted this as a question in the community area, but there is no answer up to now: Creating new Layer from joined table throws System... - Esri Community
I was informed via a technical support case that the ArcGIS Pro SDK does not currently support databases that are not configured as a geodatabase for joins. I was referred to Esri Ideas, that's why I'm suggesting this here.
@JFr87 You should be able to Run the AddJoin tool through the .sdk using this example. Does this help?
arcgis-pro-sdk-community-samples/Geoprocessing/GeoprocessingExecuteAsync at master · Esri/arcgis-pro...
Thanks for reporting this. It appears to be a bug as of now to us. We are investigating this and get back here with updates when we find more.
@JonathanNealThanks for the suggestion. I already tried that and yes, it's a workaround for the time being. I would still prefer if I could achieve my goal like in the example above.
Implemented in ArcGIS Pro 3.3.
Thank your for reporting this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.