How to retrieve field values from a query table row

447
2
Jump to solution
03-10-2020 11:41 AM
MichaelPanlasigui
New Contributor III

Greetings.  I'm performing a join query against 2 feature classes.  The QueryDef.SubFields property includes only 1 geometry field.  I then use GeoDatabase.OpenQueryTable() to get the table.  I'm trying to retrieve the field values from the rows of the result set.  Calling row.GetOriginalValue(index) throws an exception that states "The method or operation is not implemented."  Attaching source code.

I've also tried an alternate approach calling GeoDatabase.Evaluate(query_def) to get the RowCursor.  That approach does not throw an exception, but the call to row.GetOriginalValue(index) always returns null.

What is the correct way to retrieve field values from the results of a query with join?

1 Solution

Accepted Solutions
RichRuh
Esri Regular Contributor

Hi Michael,

The GetOriginalValue method is used while editing to get the pre-edit value of the field.  You cannot edit a QueryDef, so this concept doesn't apply.

You can just use the Item property. Since this is the default indexer on the Row class, you would change your provided code snippet to look like this:

foreach (var field in fields) {
   if (field.FieldType == FieldType.Geometry) continue;

   // This works
   object val = row[field.Name];

   // This works too
   int index = row.FindField(field.Name);
   object val = row[index];
}
‍‍‍‍‍‍‍‍‍‍

I hope this helps,

--Rich

View solution in original post

2 Replies
RichRuh
Esri Regular Contributor

Hi Michael,

The GetOriginalValue method is used while editing to get the pre-edit value of the field.  You cannot edit a QueryDef, so this concept doesn't apply.

You can just use the Item property. Since this is the default indexer on the Row class, you would change your provided code snippet to look like this:

foreach (var field in fields) {
   if (field.FieldType == FieldType.Geometry) continue;

   // This works
   object val = row[field.Name];

   // This works too
   int index = row.FindField(field.Name);
   object val = row[index];
}
‍‍‍‍‍‍‍‍‍‍

I hope this helps,

--Rich

MichaelPanlasigui
New Contributor III

Hi Rich,

It certainly did help.  Thanks for the quick reply!

Mike

0 Kudos