public async Task SimpleQueryDef() { await ArcGIS.Desktop.Framework.Threading.Tasks.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. } } } } } }); }
public async Task JoiningWithWhereQueryDef() { await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file")))) { QueryDef municipalEmergencyFacilitiesQueryDef = new QueryDef { SubFields = "EmergencyFacility.OBJECTID, EmergencyFacility.Shape, EmergencyFacility.FACILITYID, FacilitySite.FACILITYID, FacilitySite.FCODE", Tables = "EmergencyFacility, FacilitySite", WhereClause = "EmergencyFacility.FACNAME = FacilitySite.NAME AND EmergencyFacility.JURISDICT = 'Municipal'", }; using (RowCursor rowCursor = geodatabase.Evaluate(municipalEmergencyFacilitiesQueryDef, false)) { while (rowCursor.MoveNext()) { using (Row row = rowCursor.Current) { Feature feature = row as Feature; Geometry shape = feature.GetShape(); long objectID = Convert.ToInt64(row["EmergencyFacility.OBJECTID"]); String featureCode = Convert.ToString(row["FacilitySite.FCODE"]); IReadOnlyList<Field> fields = feature.GetFields(); //Contains one ArcGIS.Core.Data.Field objects for every subfield } } } } }); }
Target Platforms: Windows 11, Windows 10