AnsweredAssumed Answered

Unstable Row.Handle

Question asked by d.rothesri-ch-esridist Employee on May 25, 2020
Latest reply on May 26, 2020 by RRuh-esristaff

The Row.Handle property is not stable but it should according to the docs:

https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Geodatabase#unique-instancing

Other handles are. Table.Handle for instance. Am I doing something wrong? Help is much appreciated, thanks.

 

The code snippet below is a unit test. The Row.Handle is not stable in Pro App context either, e.g. running in QueuedTask.

 

[Test]
public void Compare_row_handles_SDE_LearningTest()
{
     var osaConnection = new DatabaseConnectionProperties(EnterpriseDatabaseType.Oracle)
     {
          Instance = "bla",
          AuthenticationMode = AuthenticationMode.OSA
     };

     using (var geodatabase = new Geodatabase(osaConnection))
     {
          var featureClass = geodatabase.OpenDataset<FeatureClass>("foo");
          var row0 = GetRow(featureClass, 2453);
          var row1 = GetRow(featureClass, 2453);

          Console.WriteLine("rows are equal: {0}", Equals(row0, row1));
          Console.WriteLine("rows are reference equals: {0}", ReferenceEquals(row0, row1));
          Console.WriteLine("row handles are equal: {0}", Equals(row0.Handle, row1.Handle));

          Assert.AreNotEqual(row0.Handle, row1.Handle);
     }
}


public static Row GetRow(Table table, long oid)
{
     using (var cursor = table.Search(new QueryFilter
     {
          WhereClause = $"{table.GetDefinition().GetObjectIDField()} = {oid}"
     }, false))
     {
          if (! cursor.MoveNext())
          {
               return null;
          }

          var row = cursor.Current;
          Assert.False(cursor.MoveNext(), "more than one row found");

          return row;
     }
}

Outcomes