Return Value
The parent Table of this row.
| Exception | Description |
|---|---|
| System.NotSupportedException | This instance of Row/Feature does not have a parent Table/FeatureClass (e.g., if it is obtained via a QueryDef). |
| ArcGIS.Core.Data.Exceptions.GeodatabaseException | A geodatabase-related exception has occurred. |
{
await QueuedTask.Run(() =>
{
using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file"))))
{
QueryDef adaCompilantParksQueryDef = new QueryDef
{
Tables = "Park",
WhereClause = "ADACOMPLY = 'Yes'",
};
using (RowCursor rowCursor = geodatabase.Evaluate(adaCompilantParksQueryDef, false))
{
while (rowCursor.MoveNext())
{
using (Row row = rowCursor.Current)
{
Feature feature = row as Feature;
Geometry shape = feature.GetShape();
String type = Convert.ToString(row["ADACOMPLY"]); // will be "Yes" for each row.
try
{
Table table = row.GetTable(); // Will always throw exception.
}
catch (NotSupportedException exception)
{
// Handle not supported exception.
}
}
}
}
}
});
}
{
Task<string> GetDomainStringFromFieldAsync(Row row, Field field) => QueuedTask.Run(() =>
{
// Get the table and table definition from the Row
using (Table table = row.GetTable())
using (TableDefinition tableDefinition = table.GetDefinition())
{
// Get name of subtype field
string subtypeFieldName = tableDefinition.GetSubtypeField();
// Get subtype, if any
Subtype subtype = null;
if (subtypeFieldName.Length != 0)
{
// Get value of subtype field for this row
object varSubtypeCode = row[subtypeFieldName];
long subtypeCode = (long)varSubtypeCode;
// Get subtype for this row
subtype = tableDefinition.GetSubtypes().First(x => x.GetCode() == subtypeCode);
}
// Get the coded value domain for this field
CodedValueDomain domain = field.GetDomain(subtype) as CodedValueDomain;
// Return the text string for this field
if (domain != null)
{
return domain.GetName(row[field.Name]);
}
return row[field.Name].ToString();
}
});
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)