Return Value
The MIME type of the attached document.
Exception | Description |
---|---|
ArcGIS.Core.Data.Exceptions.GeodatabaseException | A geodatabase-related exception has occurred. |
ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run |
public async Task DeletingAttachments() { await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) using (Table inspectionTable = geodatabase.OpenDataset<Table>("luCodeInspection")) { QueryFilter queryFilter = new QueryFilter { WhereClause = "ACTION = '1st Notice'" }; using (RowCursor cursor = inspectionTable.Search(queryFilter, false)) { while (cursor.MoveNext()) { using (Row currentRow = cursor.Current) { IReadOnlyList<Attachment> rowAttachments = currentRow.GetAttachments(null, true); IEnumerable<Attachment> attachments = rowAttachments.Where(attachment => attachment.GetContentType().Equals("application/pdf")); IReadOnlyList<long> attachmentIDs = attachments.Select(attachment => attachment.GetAttachmentID()) as IReadOnlyList<long>; IReadOnlyDictionary<long, Exception> failures = currentRow.DeleteAttachments(attachmentIDs); if (failures.Count > 0) { //process errors } } } } } }); }
Target Platforms: Windows 11, Windows 10