Hello everyone,
I have created a code that duplicates feature classes and tables and then duplicates the existing relationships between them.
This is the workflow:
1. duplicate fcl and tables
2. for each fcl or table I copy the information of the relationship
3. than I create the relationships for the duplicate fcl or table using the following code
IFields campiAttributed = null;
if (relationshipEsistente.IsAttributed)
{
try
{
ITable table = (AttributedRelationshipClass)relationshipEsistente as ITable;
campiAttributed = table.Fields;
}
catch (Exception ee)
{ }
}
try
{
IRelationshipClass relClass = featureWorkspace.CreateRelationshipClass
(nomeRelazione, (IObjectClass)featureWorkspace.OpenTable(nome + "__" + nomeTabellaOrig),
(IObjectClass)featureWorkspace.OpenTable(nome + "__" + nomeTabellaDest), relationshipEsistente.ForwardPathLabel, relationshipEsistente.BackwardPathLabel,
relationshipEsistente.Cardinality, relationshipEsistente.Notification, relationshipEsistente.IsComposite, relationshipEsistente.IsAttributed, campiAttributed,
relationshipEsistente.OriginPrimaryKey, relationshipEsistente.DestinationPrimaryKey, relationshipEsistente.OriginForeignKey, relationshipEsistente.DestinationForeignKey);
}
The problem is this, the 1:1 and 1:N relationship are replicated correctly, the attributed relationship N:M with additional attributes is created correctly but is empty. I found out this problem because I can't navigate between objects in the fcl and table, than I inspected the relationship with the tool Make Query Table (Data Management) and it is empty.
Should I use an alternative way?
Thank you.