Parameters
- table
- The table of the row to update.
- oid
- The FeatureID of the row to update.
- fieldIndex
- The field index to update
- value
- The new value.
| Exception | Description |
|---|---|
| ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run. |
// Modifies the "NAME" attribute of a specified feature and then splits the feature using the provided polyline, all within a single sequential edit operation. // perform an edit and then a split as one operation. await QueuedTask.Run(() => { var newName = "Modified then Split"; var queryFilter = new QueryFilter() { WhereClause = "OBJECTID = " + objectId.ToString() }; // create an edit operation and name. var op = new EditOperation { Name = "modify followed by split", // set the ExecuteMode ExecuteMode = ExecuteModeType.Sequential }; using (var rowCursor = layer.Search(queryFilter)) { while (rowCursor.MoveNext()) { using var feature = rowCursor.Current as ArcGIS.Core.Data.Feature; op.Modify(feature, "NAME", newName); } } op.Split(layer, objectId, splitLine); if (!op.IsEmpty) { bool result = op.Execute(); } // else // The operation doesn't make any changes to the database so if executed it will fail });
await QueuedTask.Run(() => { // get selected feature into inspector var selectedFeatures = activeMap.GetSelection(); var insp = new Inspector(); insp.Load(selectedFeatures.ToDictionary().Keys.First(), selectedFeatures.ToDictionary().Values.First()); // read a blob field and save to a file var msw = new MemoryStream(); msw = insp["BlobField"] as MemoryStream; using (FileStream file = new(@"d:\temp\blob.jpg", FileMode.Create, FileAccess.Write)) { msw.WriteTo(file); } // read file into memory stream var msr = new MemoryStream(); using (FileStream file = new(@"d:\images\Hydrant.jpg", FileMode.Open, FileAccess.Read)) { file.CopyTo(msr); } //put the memory stream in the blob field and save to feature var op = new EditOperation() { Name = "Blob Inspector" }; insp["Blobfield"] = msr; op.Modify(insp); if (!op.IsEmpty) { var result = op.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not } });
var compressedRasterMapView = MapView.Active; if (compressedRasterMapView == null) return; await QueuedTask.Run(() => { //Open the raster dataset on disk and create a compressed raster value dataset object var dataStore = new ArcGIS.Core.Data.FileSystemDatastore(new ArcGIS.Core.Data.FileSystemConnectionPath(new Uri(@"e:\temp"), ArcGIS.Core.Data.FileSystemDatastoreType.Raster)); using (var fileRasterDataset = dataStore.OpenDataset<ArcGIS.Core.Data.Raster.RasterDataset>("Hydrant.jpg")) { var storageDef = new ArcGIS.Core.Data.Raster.RasterStorageDef(); storageDef.SetCompressionType(ArcGIS.Core.Data.Raster.RasterCompressionType.JPEG); storageDef.SetCompressionQuality(90); var rv = new ArcGIS.Core.Data.Raster.RasterValue(); rv.SetRasterDataset(fileRasterDataset); rv.SetRasterStorageDef(storageDef); var sel = compressedRasterMapView.Map.GetSelection(); //insert a raster value object into the raster field var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); insp.Load(sel.ToDictionary().Keys.First(), sel.ToDictionary().Values.First()); insp["Photo"] = rv; var op = new EditOperation() { Name = "Raster Inspector" }; op.Modify(insp); if (!op.IsEmpty) { var result = op.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not } } });
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)