[GIS] Benefits of relationship classes and how they can be accessed in c#

arcgis-10.0arcobjectscesri-geodatabaserelationship-class

At the moment I've a personal geodatabase with two imported feature classes from shape files and an own created table. This table has columns for the IDs of the elements in the two feature classes. With ArcCatalog I've created two relationship classes between each sfeature class and the table. Both are 1:1 relationsships. Within ArcMap the user can open the table and get access to more detailed informations by using this relationsships (menu -> Related Tables).

Background: One feature class holds features consisting of Polylines, the other features consisting of Points. With the Table I can create a logical relationship between one Point and one Polyline and can add more informations in this table which are only valid for this special relation.

Now I've to work with this table in C# and I've to access the other feature classes too. It's no problem to read the IDs out of the table and start a QueryFilter for the feature class where I need the informations from.

Sure, this is one possible way but there must exist a more efficient way where I can use the relationship classes for faster operations.

Does anybody know how I can query the relationship classes to get all informations at the same time without querying two different tables "manually"?

Thanks a lot!

Edit:

To be more specific. If the table has the two fields ID_EdgeTo and ID_EdgeFrom and one field has a relationship to the feature class EdgesTo and the other to EdgesFrom.

When I get through the rows and see a combination of ID_EdgeTo and ID_EdgeFrom I want to query the relationship classes to get more information for the ID's in this specific row.

Its more about whether the relationship classes are retrievable and how this has to be done. The table in the database has the form like a "manually created" relationship class with relationship attributes

Best Answer

Based on your additional notes it sounds like you will want to use the IRelationshipClass.GetObjectsRelatedToObject method, at least for starters.

For better performance you might consider using one of the other methods, such as GetObjectsRelatedToObjectSet that takes a set of input objects though. This will reduce the number of round trips to the database if you are doing this in batch.

Additionally if you want to specify a QueryFilter over a given set of input objects (this might not be necessary if your cursor is already being filtered), take a look at IRelationshipClass2.GetObjectsMatchingObjectSetEx.

For code examples I would suggest searching the ESRI forums (new and old), as well as this site: Example search

Some relevant results:

Without having a relevant sample dataset I am reluctant to write a code example myself. Perhaps you could upload an ESRI XML Workspace document for a subset of your data, and describe the desired user interaction workflow, inputs and outputs.

Also refer to the available documentation:

Relationship Objects
(source: arcgis.com)

Related Question