AnsweredAssumed Answered

Data Joins and Relationships

Question asked by belowzero8 on Sep 12, 2013
Latest reply on Sep 17, 2013 by belowzero8
Say I have the two attached tables that I want to join together in code using the "J_Fld".  As you can see, it is a one-to-many join and there will be one row in the left table that does not have a match in the right table.  I want to get a result that returns "all-results" like the join options in ArcMap (so include the one without a relationship).  If I used a QueryDefinition I get everything but the one without a relationship.

The API has code for a IRelationshipClass:
// Build a memory relationship class. Type memRelClassFactoryType = Type.GetTypeFromProgID(     "esriGeodatabase.MemoryRelationshipClassFactory"); IMemoryRelationshipClassFactory memRelClassFactory =      (IMemoryRelationshipClassFactory)Activator.CreateInstance(memRelClassFactoryType)     ; IRelationshipClass relationshipClass = memRelClassFactory.Open("ParcelsOwners",     parcelsFeatureClass, "PARCEL_ID", (IObjectClass)ownersTable, "PARCEL_ID",      "Is Owned By", "Owns", esriRelCardinality.esriRelCardinalityOneToOne);  // Open the RelQueryTable as a feature class. Type rqtFactoryType = Type.GetTypeFromProgID("esriGeodatabase.RelQueryTableFactory"); IRelQueryTableFactory rqtFactory = (IRelQueryTableFactory)Activator.CreateInstance     (rqtFactoryType); ITable relQueryTable = (ITable)rqtFactory.Open(relationshipClass, false, null, null,     String.Empty, false, false);


If I change the cardinality to "esriRelCardinalityManyToMany" the return table only has 4 rows in it.  It looks like no matter what it returns a one-to-one and takes a "first case wins" approach.

I was thinking the way to go about it is IRelationshipClass.GetRelationshipForObject, but it doesn't seem to like being passed a table row as an object.

Any ideas?

Attachments

Outcomes