<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Support for EditOperation.Callback() on non-versionen tabels in enterprise geodatabase? in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/support-for-editoperation-callback-on-non/m-p/1363497#M10928</link>
    <description>&lt;P&gt;I have created a new enterprise geodatabase on SQL server instance and placed one non-versioned table called in_PubRC_Lines in the geodatabase. When I try run my sample code attached below – a simple demo example that uses the callback function to delete a row – I get the following error: “This edit failed because a short edit operation cannot be performed on versioned data.”&lt;/P&gt;&lt;P&gt;A key point in the code is I set the EditOperationType = EditOperationType.Short. This should the correct operation type for non-versionen enterprise geodatabases.&lt;/P&gt;&lt;P&gt;If I replace the EditOperation.Callback() with a EditOperation.Delete() the code seems to be running fine.&lt;/P&gt;&lt;P&gt;So, this makes me assume that EditOperation.Callback() is only supported for EditOperationType.Long (and for enterprise geodatabase that means versioned data). Unfortunately, the documentation does not clarify this.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;	internal class Button1 : Button
	{
		protected override async void OnClick()
		{
			string tableName = "in_PubRC_Lines";
			
			var map = MapView.Active?.Map;
			if (map == null) return;
			var searchThisTable = map.GetStandaloneTablesAsFlattenedList().Where(l =&amp;gt; l.Name.Equals(tableName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
			if (searchThisTable == null)
			{
				MessageBox.Show($@"Cannot find this table: {tableName}");
				return;
			}
			var table = await QueuedTask.Run(() =&amp;gt; { return searchThisTable.GetTable(); });

			var deleteOperation = new EditOperation()
			{
				SelectNewFeatures = false,
				EditOperationType = EditOperationType.Short,
				Name = $"Delete test"
			};

			await DeleteDataAsync(table, "ID IN (1)", deleteOperation);
			//await QueuedTask.Run(() =&amp;gt; { deleteOperation.Delete(table, 1); });

			if (!deleteOperation.IsEmpty)
			{
				var res  = await deleteOperation.ExecuteAsync();

				if (!res) 
				{
					MessageBox.Show(deleteOperation.ErrorMessage);
				}
			}
		}

		private async Task DeleteDataAsync(Table table, string whereClause, EditOperation editOperation)
		{
			await QueuedTask.Run(() =&amp;gt;
			{

				editOperation.Callback(context =&amp;gt;
				{
					QueryFilter qf = new QueryFilter();
					qf.WhereClause = whereClause;
					using (var cursor = table.Search(qf, false))
					{
						while (cursor.MoveNext())
						{
							using (var row = cursor.Current)
							{
								context.Invalidate(row);
								row.Delete();
							}
						}
					}
				}, table);
			});
		}
	}&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 21 Dec 2023 10:20:01 GMT</pubDate>
    <dc:creator>StephenCochrane</dc:creator>
    <dc:date>2023-12-21T10:20:01Z</dc:date>
    <item>
      <title>Support for EditOperation.Callback() on non-versionen tabels in enterprise geodatabase?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/support-for-editoperation-callback-on-non/m-p/1363497#M10928</link>
      <description>&lt;P&gt;I have created a new enterprise geodatabase on SQL server instance and placed one non-versioned table called in_PubRC_Lines in the geodatabase. When I try run my sample code attached below – a simple demo example that uses the callback function to delete a row – I get the following error: “This edit failed because a short edit operation cannot be performed on versioned data.”&lt;/P&gt;&lt;P&gt;A key point in the code is I set the EditOperationType = EditOperationType.Short. This should the correct operation type for non-versionen enterprise geodatabases.&lt;/P&gt;&lt;P&gt;If I replace the EditOperation.Callback() with a EditOperation.Delete() the code seems to be running fine.&lt;/P&gt;&lt;P&gt;So, this makes me assume that EditOperation.Callback() is only supported for EditOperationType.Long (and for enterprise geodatabase that means versioned data). Unfortunately, the documentation does not clarify this.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;	internal class Button1 : Button
	{
		protected override async void OnClick()
		{
			string tableName = "in_PubRC_Lines";
			
			var map = MapView.Active?.Map;
			if (map == null) return;
			var searchThisTable = map.GetStandaloneTablesAsFlattenedList().Where(l =&amp;gt; l.Name.Equals(tableName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
			if (searchThisTable == null)
			{
				MessageBox.Show($@"Cannot find this table: {tableName}");
				return;
			}
			var table = await QueuedTask.Run(() =&amp;gt; { return searchThisTable.GetTable(); });

			var deleteOperation = new EditOperation()
			{
				SelectNewFeatures = false,
				EditOperationType = EditOperationType.Short,
				Name = $"Delete test"
			};

			await DeleteDataAsync(table, "ID IN (1)", deleteOperation);
			//await QueuedTask.Run(() =&amp;gt; { deleteOperation.Delete(table, 1); });

			if (!deleteOperation.IsEmpty)
			{
				var res  = await deleteOperation.ExecuteAsync();

				if (!res) 
				{
					MessageBox.Show(deleteOperation.ErrorMessage);
				}
			}
		}

		private async Task DeleteDataAsync(Table table, string whereClause, EditOperation editOperation)
		{
			await QueuedTask.Run(() =&amp;gt;
			{

				editOperation.Callback(context =&amp;gt;
				{
					QueryFilter qf = new QueryFilter();
					qf.WhereClause = whereClause;
					using (var cursor = table.Search(qf, false))
					{
						while (cursor.MoveNext())
						{
							using (var row = cursor.Current)
							{
								context.Invalidate(row);
								row.Delete();
							}
						}
					}
				}, table);
			});
		}
	}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 21 Dec 2023 10:20:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/support-for-editoperation-callback-on-non/m-p/1363497#M10928</guid>
      <dc:creator>StephenCochrane</dc:creator>
      <dc:date>2023-12-21T10:20:01Z</dc:date>
    </item>
  </channel>
</rss>

