Select to view content in your preferred language

Get the tables joined to a feature layer

182
3
Jump to solution
3 weeks ago
JFr87
by
Occasional Contributor

Hi,

is there a way to determine which tables are joined to a feature layer using the ArcGIS Pro SDK for .NET? 

For example, I have a Feature Layer "Trees" joined to a Table "Trees_Metadata". I performed the join using the "Joins and Relates" => "Add Join..." function. How can I use the ArcGIS Pro SDK for .NET to find out retrospectively which table the "Trees" layer is joined to?

Thanks in advance

0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi,

You need to start from FeatureLayer or StandaloneTable to get origin or joined table.

        protected override async void OnClick()
        {
            var map = MapView.Active.Map;
            if (map == null || map.Layers.Count == 0)
            {
                MessageBox.Show("No layers found in the map.");
                return;
            }

            var bfl = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(layer => layer.Name.Equals("your layer name"));

            if(bfl.HasJoins)
            {
                await QueuedTask.Run(() => {
                    var table1 = bfl.GetTable().GetJoin().GetOriginTable();
                    var table2 = bfl.GetTable().GetJoin().GetJoinedTable();
                    // your code here

                });  
            }
        }

View solution in original post

0 Kudos
3 Replies
JFr87
by
Occasional Contributor

I've already tried to determine the joined table using FeatureClass.GetJoin(). I get the following exception:

System.InvalidOperationException: "'Trees' is not a joined table."
'Baumgruppen' is not a joined table.
  at ArcGIS.Core.Data.Table.GetJoin()

FeatureClass.IsJoinedTable() also returns false, even though I created a join as mentioned above.

0 Kudos
GKmieliauskas
Esri Regular Contributor

Hi,

You need to start from FeatureLayer or StandaloneTable to get origin or joined table.

        protected override async void OnClick()
        {
            var map = MapView.Active.Map;
            if (map == null || map.Layers.Count == 0)
            {
                MessageBox.Show("No layers found in the map.");
                return;
            }

            var bfl = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(layer => layer.Name.Equals("your layer name"));

            if(bfl.HasJoins)
            {
                await QueuedTask.Run(() => {
                    var table1 = bfl.GetTable().GetJoin().GetOriginTable();
                    var table2 = bfl.GetTable().GetJoin().GetJoinedTable();
                    // your code here

                });  
            }
        }
0 Kudos
JFr87
by
Occasional Contributor

This example helped me a lot. Thanks.

0 Kudos