ArcGIS Explorer Component Help |
TableRelationship..::.CreateJoinedTable Method (TableJoinType, Filter) |
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 but only those rows which satisfy the specified join parameters.
Namespace:
ESRI.ArcGISExplorer.DataAssembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public Table CreateJoinedTable( TableJoinType joinType, Filter filter ) |
Visual Basic (Declaration) |
---|
Public Function CreateJoinedTable ( _ joinType As TableJoinType, _ filter As Filter _ ) As Table |
Parameters
- joinType
- Type: ESRI.ArcGISExplorer.Data..::.TableJoinType
One of the TableJoinType values which, in conjunction with the filter, determines the content of the joined table.
- filter
- Type: ESRI.ArcGISExplorer.Data..::.Filter
A Filter object containing additional search criteria which, in conjunction with the joinType, determines the content of the joined 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, but does not have the flexibility to specify additional search criteria.
Examples
The code below creates an in-memory TableRelationship between a geodatabase feature class and a dBase
table then joins them together, but restricts the content of the joined Table to matching rows which satisfy
the search criteria specified in the Filter object.
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); //Join tables applying a filter which only returns north african countries which have matching records in the DEMOG table Table joinedTable = cntryPopRel.CreateJoinedTable(TableJoinType.KeepOnlyMatchingRows, new Filter("Country.Region='Northern Africa'") ); //Print out all records from the joined table foreach (Row row in joinedTable.GetRows()) { System.Diagnostics.Debug.Print(row.Values["country.NAME"].ToString()); for (int i = 0; i < joinedTable.Columns.Count; i++) { System.Diagnostics.Debug.Print(joinedTable.Columns[i].Name + ": " + row.Values[i].ToString()); } System.Diagnostics.Debug.Print(""); }
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) 'Join tables applying a filter which only returns north african countries which have matching records in the DEMOG table Dim joinedTable As Table = cntryPopRel.CreateJoinedTable(TableJoinType.KeepOnlyMatchingRows, New Filter("Country.Region='Northern Africa'")) 'Print out all records from the joined table For Each r As Row In joinedTable.GetRows() System.Diagnostics.Debug.Print(r.Values.Item("country.NAME").ToString()) For i As Integer = 0 To joinedTable.Columns.Count - 1 System.Diagnostics.Debug.Print(joinedTable.Columns.Item(i).Name & ": " & r.Values.Item(i).ToString()) Next System.Diagnostics.Debug.Print("") Next