I already know how to do a table join with ArcObjects, via the IDisplayTable
, IMemoryRelationshipClassFactory
etc. interfaces. Here are some links to resources that have example code for this:
What I need to know is, how do I undo, i.e. remove such a join?
Once I've joined a standalone table to a feature layer, I end up with references to:
an
IRelationshipClass
(resulting from the join operation);an
ITable
/IStandaloneTable
/IDisplayTable
(the table that was joined to the feature layer); andan
IFeatureLayer
(the feature layer to which the table was joined).
Do these interfaces, or rather the objects behind them, allow unjoining at all? I've seen that IRelationshipClass
has various DeleteRelationship…
methods, but I can't see how they could work towards that end.
Answer
Code below works for me for a featurelayer. Similar logic could be used for a standalone table.
private void RemoveAllJoins(IFeatureLayer fLayer)
{
var dispTable = fLayer as IDisplayTable;
var rqt = dispTable.DisplayTable as IRelQueryTable;
if (rqt != null)
{
Debug.Print("source: {0}", ((IDataset)rqt.DestinationTable).Name);
Debug.Print("dest: {0}", ((IDataset)rqt.SourceTable).Name);
fLayer.FeatureClass = (IFeatureClass)rqt.DestinationTable;
}
else
Debug.Print("there are no joins");
}
The documentation for IRelQueryTable at 10 seems to be missing this important graphic, that appears in 8.3 help doc:
No comments:
Post a Comment