ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data Namespace / JoinDescription Class / TargetFields Property
Example

In This Topic
    TargetFields Property
    In This Topic
    Gets or sets the fields from the left table which have to be included during the join operation.
    Syntax
    public IReadOnlyList<Field> TargetFields {get; set;}
    Public Property TargetFields As IReadOnlyList(Of Field)
    Remarks
    Note that if the join is Backward, the target fields are from the right table.
    Example
    Joining two tables from different geodatabases
    public async Task JoinTablesFromDifferentGeodatabases()
    {
        await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
        {
            using (Geodatabase sourceGeodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri("Path \\ to \\Geodatabase \\ one"))))
            using (Geodatabase destinationGeodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri("Path \\ to \\Geodatabase \\ two"))))
            using (Table sourceTable = sourceGeodatabase.OpenDataset<Table>("State"))
            using (Table destinationTable = destinationGeodatabase.OpenDataset<Table>("Cities"))
            {
                Field primaryKeyField = sourceTable.GetDefinition().GetFields().FirstOrDefault(field => field.Name.Equals("State.State_Abbreviation"));
                Field foreignKeyField = destinationTable.GetDefinition().GetFields().FirstOrDefault(field => field.Name.Equals("Cities.State"));
    
                VirtualRelationshipClassDescription virtualRelationshipClassDescription = new VirtualRelationshipClassDescription(primaryKeyField, foreignKeyField, RelationshipCardinality.OneToMany);
    
                using (RelationshipClass relationshipClass = sourceTable.RelateTo(destinationTable, virtualRelationshipClassDescription))
                {
                    JoinDescription joinDescription = new JoinDescription(relationshipClass)
                    {
                        JoinDirection = JoinDirection.Forward,
                        JoinType = JoinType.InnerJoin,
                        TargetFields = sourceTable.GetDefinition().GetFields()
                    };
    
                    using (Join join = new Join(joinDescription))
                    {
                        Table joinedTable = join.GetJoinedTable();
    
                        //Process the joined table. For example ..
                        using (RowCursor cursor = joinedTable.Search())
                        {
                            while (cursor.MoveNext())
                            {
                                using (Row row = cursor.Current)
                                {
                                    // Use Row
                                }
                            }
                        }
                    }
                }
            }
        });
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also