public static IEnumerable <IFeature> GetDerivedTableGeometryFeatures( [NotNull] IObject obj, [NotNull] ObjectDataset dataset, [NotNull] IModelContext modelContext) { Assert.ArgumentNotNull(obj, nameof(obj)); Assert.ArgumentNotNull(dataset, nameof(dataset)); Assert.ArgumentNotNull(modelContext, nameof(modelContext)); // TODO move elsewhere - domain? IObjectDataset? use objectrepository (moved from AE)? var relationList = new List <IRelationshipClass>(); IWorkspaceContext workspaceContext = null; foreach (AssociationEnd associationEnd in dataset.GetAssociationEnds()) { if (!(associationEnd.OppositeDataset is VectorDataset) || associationEnd.Association.NotUsedForDerivedTableGeometry) { continue; } // make sure to open the relationship class from the same workspace context as the dataset if (workspaceContext == null) { workspaceContext = modelContext.GetWorkspaceContext(dataset); Assert.NotNull(workspaceContext, "Unable to determine workspace context for dataset {0}", dataset); } IRelationshipClass relationshipClass = workspaceContext.OpenRelationshipClass(associationEnd.Association); if (relationshipClass != null) { relationList.Add(relationshipClass); } } return(GdbQueryUtils.GetRelatedObjectList(obj, relationList).Cast <IFeature>()); }
public void CanGetRelated() { IFeatureWorkspace ws = OpenTestWorkspace(); IRelationshipClass rc = ws.OpenRelationshipClass("TOPGIS_TLM.TLM_STRASSE_NAME"); NUnit.Framework.Assert.AreEqual(rc.Cardinality, esriRelCardinality.esriRelCardinalityOneToMany); int count = 0; foreach (IRow row in GdbQueryUtils.GetRows((ITable)rc.OriginClass, false)) { var obj = (IObject)row; IList <IObject> features = GdbQueryUtils.GetRelatedObjectList(obj, new[] { rc }); count += features.Count; } NUnit.Framework.Assert.Greater(count, 0); }