1

I have been struggling with this issue for hours now and am wondering if anyone else has encountered this.

I have a feature class (ADDRESS_MANAGER.GIS_INF_ADDRESS_P) and a table (ADDRESS_MANAGER.GIS_TBL_ADDRESSCARD_B).

Using ArcCatalog, I have verified the IDs of the feature class is 987 and the address card table is 981. I have verified the relationship exists from the feature class to the address card table (Relationship = ADDRESS_MANAGER.AddressCardHasAddress / Label = AddressCard / Origin=ADDRESS_MANAGER.GIS_INF_ADDRESS_P).

However, no relationship classes are returned when I run this code:

var sourceId = sourceTable.GetID().ToString(); // returns "987"
var destId = destTable.GetID().ToString(); // returns "981"
IReadOnlyList<RelationshipClass> relationshipClasses = geodb.OpenRelationshipClass(sourceId, destId);

I have verified the geodb object does indeed point to the geodatabase that holds both of these layers -- geodb is set directly from the feature class. Both layer IDs are correct, and there is definitely a relationship class between them. I am porting old ArcObject code over that did something similar, and I cannot figure out how to actually get this RelationshipClass anymore without hardcoding a reference to it.

This is ran in QueuedTask.Run per the documentation. It doesn't seem to matter if I set up geodb by opening the appropriate SDE file, or if I set it from the feature class (the geodb is an versioned enterprise geodabatase -- Oracle). Note that I can open the relationship class by using (RelationshipClass relationshipClass = geodb.OpenDataset<RelationshipClass>("ADDRESS_MANAGER.AddressCardHasAddress"))

This is in ArcGIS Pro 2.2 - using C# / .NET 4.6.2

  • It might be in your best interest to post on the prosdk geomet forum. Members of that team actively monitor it. I’m not sure how much time they spend here on GIS.se. – KHibma Sep 6 '18 at 11:49
  • I posted there a few days ago and go no response. I might contact our Esri rep directly – Thomas Sep 6 '18 at 16:13
  • Ahhh. Then it’s probably not a simple answer...might need to use tech support – KHibma Sep 6 '18 at 16:46
0

This was answered by Esri on GeoNet.

As currently implemented, the OpenRelationshipClass() method only works with feature service databases. We will review this implementation in a future release to see if we can extend it to cover additional database types. And we’ll definitely clarify the documentation as soon as possible.

To open a relationship class with an SDE or file geodatabase, you need to use the Geodatabase.OpenDataset method, passing in the name of the relationship class. If you don’t know the name of the relationship class you can find it and open it up using code like the following:

IReadOnlyList<RelationshipClass> OpenRelationshipClass(Geodatabase geodatabase, string originClassName, string destinationClassName)
{
 List<RelationshipClass> relationshipClasses = new List<RelationshipClass>();
 IReadOnlyList<RelationshipClassDefinition> relationshipClassDefinitions = geodatabase.GetDefinitions<RelationshipClassDefinition>();
 foreach (RelationshipClassDefinition relationshipClassDefinition in relationshipClassDefinitions)
 {
    if (relationshipClassDefinition.GetOriginClass() == originClassName && relationshipClassDefinition.GetDestinationClass() == destinationClassName)
    {
       relationshipClasses.Add(geodatabase.OpenDataset<RelationshipClass>(relationshipClassDefinition.GetName()));
    }
    relationshipClassDefinition.Dispose();
 }
 return relationshipClasses;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.