You could also 'read' the ActualContainingObjectName property from a Relation's PK or FK field by use of the GetPKEntityFieldCore/GetFKEntityFieldCore property.
Please look at the following sample code where we inspect relations within a bucket to create a cloned version of the relations to create seamless access to an archive database :
Private Function GetClonedRelationCollection(ByVal sourceRelations As IRelationCollection) As IRelationCollection
If sourceRelations IsNot Nothing AndAlso sourceRelations.Count > 0 Then
Dim result As New RelationCollection
For Each relation As IEntityRelation In sourceRelations
If archiveEntityList.Contains(relation.GetPKEntityFieldCore(0).ActualContainingObjectName) OrElse _
archiveEntityList.Contains(relation.GetFKEntityFieldCore(0).ActualContainingObjectName) Then
Dim newRelation As New EntityRelation(GetClonedEntityField(relation.GetPKEntityFieldCore(0)), _
GetClonedEntityField(relation.GetFKEntityFieldCore(0)), relation.TypeOfRelation, _
relation.StartEntityIsPkSide, relation.MappedFieldName)
result.Add(newRelation, relation.AliasStartEntity, relation.AliasEndEntity, relation.JoinType)
Else
result.Add(relation, relation.AliasStartEntity, relation.AliasEndEntity, relation.JoinType)
End If
Next
Return result
End If
Return Nothing
End Function
Regards,
Danny