ArcGIS Explorer Component Help |
TableRelationship..::.CreateMemoryRelationship Method |
TableRelationship Class Example See Also |
Creates an in-memory relationship between two tables.
Namespace:
ESRI.ArcGISExplorer.DataAssembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public static TableRelationship CreateMemoryRelationship( string name, Table originTable, string originKeyColumnName, string originForeignKeyColumnName, Table destinationTable, TableRelationshipCardinality cardinality ) |
Visual Basic (Declaration) |
---|
Public Shared Function CreateMemoryRelationship ( _ name As String, _ originTable As Table, _ originKeyColumnName As String, _ originForeignKeyColumnName As String, _ destinationTable As Table, _ cardinality As TableRelationshipCardinality _ ) As TableRelationship |
Parameters
- name
- Type: System..::.String
The name of the relationship.
- originTable
- Type: ESRI.ArcGISExplorer.Data..::.Table
A Table object which represents the origin side of the relationship.
- originKeyColumnName
- Type: System..::.String
The name of the key column in the originTable.
- originForeignKeyColumnName
- Type: System..::.String
The name of the key column in the destinationTable.
- destinationTable
- Type: ESRI.ArcGISExplorer.Data..::.Table
A Table object which represents the destination side of the relationship.
- cardinality
- Type: ESRI.ArcGISExplorer.Data..::.TableRelationshipCardinality
One of the TableRelationshipCardinality values which describes the relationship. Valid values are OneToOne or OneToMany, but a ManyToMany value is invalid.
Return Value
A TableRelationship object which represents an in-memory linkage between two tables.Examples
The code below returns the name of the property owners (owners table) for the specified land parcel (parcels shapefile)
by creating an in-memory relationship between the two tables and then using the GetRelatedRows method.
CopyC#
DataDirectory dir = new DataDirectory(@"C:\Data\Montgomery"); //Open the parcels shapefile Table parcels = dir.OpenTable("parcels"); //Open the owners dBase table Table owners = dir.OpenTable("owners"); //Create an in-memory TableRelationship between the two tables TableRelationship rel = TableRelationship.CreateMemoryRelationship("MemParcelsOwners", parcels, "property_i", "property_i", owners, TableRelationshipCardinality.OneToMany); //Get a single parcel Row parcel = parcels.GetRow(3510); //The parcels table is related to the owners table through the MemParcelOwners in-memory TableRelationship. foreach (Row owner in parcel.GetRelatedRows(rel)) { //Print the names of the owners of this parcel System.Diagnostics.Debug.Print(owner.Values["owner_name"].ToString()); }
CopyVB.NET
Dim dir As DataDirectory = New DataDirectory("C:\Data\Montgomery") 'Open the parcels shapefile Dim parcels As Table = dir.OpenTable("parcels") 'Open the owners dBase table Dim owners As Table = dir.OpenTable("owners") 'Create an in-memory TableRelationship between the two tables Dim rel As TableRelationship = TableRelationship.CreateMemoryRelationship("MemParcelsOwners", parcels, "property_i", _ "property_i", owners, TableRelationshipCardinality.OneToMany) 'Get a single parcel Dim parcel As Row = parcels.GetRow(3510) 'The parcels table is related to the owners table through the MemParcelsOwners TableRelationship. For Each owner As Row In parcel.GetRelatedRows(rel) 'Print the names of the owners of this parcel System.Diagnostics.Debug.Print(owner.Values.Item("owner_name").ToString()) Next