public void DeleteRelationship( Row originRow, Row destinationRow )
Public Sub DeleteRelationship( _ ByVal originRow As Row, _ ByVal destinationRow As Row _ )
public void DeleteRelationship( Row originRow, Row destinationRow )
Public Sub DeleteRelationship( _ ByVal originRow As Row, _ ByVal destinationRow As Row _ )
Exception | Description |
---|---|
System.ArgumentException | originRow or destinationRow is null. |
System.NotSupportedException | This relationship class does not support this operation. For example, it is a virtual relationship class. |
ArcGIS.Core.Data.Exceptions.GeodatabaseException | A geodatabase-related exception has occurred. |
public async Task DeletingARelationship() { await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file")))) using (RelationshipClass relationshipClass = geodatabase.OpenDataset<RelationshipClass>("LocalGovernment.GDB.luCodeViolationHasInspections")) using (FeatureClass violationsFeatureClass = geodatabase.OpenDataset<FeatureClass>("LocalGovernment.GDB.luCodeViolation")) { QueryFilter queryFilter = new QueryFilter { WhereClause = "LOCDESC LIKE '%Jefferson%'" }; using (RowCursor rowCursor = violationsFeatureClass.Search(queryFilter, false)) { if (!rowCursor.MoveNext()) return; using (Row jeffersonAveViolation = rowCursor.Current) { IReadOnlyList<Row> relatedDestinationRows = relationshipClass.GetRowsRelatedToOriginRows(new List<long> { jeffersonAveViolation.GetObjectID() }); try { EditOperation editOperation = new EditOperation(); editOperation.Callback(context => { foreach (Row relatedDestinationRow in relatedDestinationRows) { try { relationshipClass.DeleteRelationship(jeffersonAveViolation, relatedDestinationRow); } catch (GeodatabaseRelationshipClassException exception) { Console.WriteLine(exception); } } }, relationshipClass); bool editResult = editOperation.Execute(); } finally { foreach (Row row in relatedDestinationRows) row.Dispose(); } } } } }); }
Target Platforms: Windows 11, Windows 10