ArcGIS Explorer Component Help |
TableRelationship..::.CreateJoinedTable Method |
TableRelationship Class Example See Also |
Creates a new Table by joining the tables defined in the TableRelationship which has all the columns from
both tables and all the rows from the origin table.
Namespace:
ESRI.ArcGISExplorer.DataAssembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public Table CreateJoinedTable() |
Visual Basic (Declaration) |
---|
Public Function CreateJoinedTable As Table |
Return Value
A new Table object which is the result of joining the tables defined in the TableRelationship.Remarks
Joins can only be performed where the relationship Cardinality is one-to-one. Performance will be improved if the columns participating in the join are indexed. When accessing columns in the joined table by name, use the fully qualified form: "table_name.column_name". Using the Table.Join method avoids the need to explicitly create a TableRelationship when joining two tables.
Examples
The code below creates an in-memory TableRelationship between a geodatabase feature class and a dBase
table then joins them.
CopyC#
//Open geodatabase feature class Table countries = Table.OpenFileGeodatabaseTable(@"C:\Data\World.gdb", "country"); //Open dBase file Table popStats = Table.OpenShapefile(@"C:\Data\World\DEMOG.dbf"); //Create a TableRelationship between the tables TableRelationship cntryPopRel = TableRelationship.CreateMemoryRelationship("countryDEMOG", countries, "FIPS_CODE", "FIPS_CODE", popStats, TableRelationshipCardinality.OneToOne); //Create an in-memory join between the two tables Table joinedTable = cntryPopRel.CreateJoinedTable(); //Print out the life expectancy for all countries foreach (Row row in joinedTable.GetRows()) { string output = row.Values["country.Name"].ToString() + ": " + row.Values["DEMOG.LIFE_EXP"].ToString(); System.Diagnostics.Debug.Print(output); }
CopyVB.NET
'Open geodatabase feature class Dim countries As Table = Table.OpenFileGeodatabaseTable("C:\Data\World.gdb", "country") 'Open dBase file Dim popStats As Table = Table.OpenShapefile("C:\Data\World\DEMOG.dbf") 'Create a TableRelationship between the tables Dim cntryPopRel As TableRelationship = TableRelationship.CreateMemoryRelationship("countryDEMOG", countries, "FIPS_CODE", _ "FIPS_CODE", popStats, TableRelationshipCardinality.OneToOne) 'Create an in-memory join between the two tables Dim joinedTable As Table = cntryPopRel.CreateJoinedTable() 'Print out the life expectancy for all countries For Each r As Row In joinedTable.GetRows() Dim output As String = r.Values.Item("country.Name").ToString() & ": " & r.Values.Item("DEMOG.LIFE_EXP").ToString() System.Diagnostics.Debug.Print(output) Next