public async Task SearchingAFeatureClass() { await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) using (FeatureClass schoolBoundaryFeatureClass = geodatabase.OpenDataset<FeatureClass>("LocalGovernment.GDB.SchoolBoundary")) { // Using a spatial query filter to find all features which have a certain district name and lying within a given Polygon. SpatialQueryFilter spatialQueryFilter = new SpatialQueryFilter { WhereClause = "DISTRCTNAME = 'Indian Prairie School District 204'", FilterGeometry = new PolygonBuilderEx(new List<Coordinate2D> { new Coordinate2D(1021880, 1867396), new Coordinate2D(1028223, 1870705), new Coordinate2D(1031165, 1866844), new Coordinate2D(1025373, 1860501), new Coordinate2D(1021788, 1863810) }).ToGeometry(), SpatialRelationship = SpatialRelationship.Within }; using (RowCursor indianPrairieCursor = schoolBoundaryFeatureClass.Search(spatialQueryFilter, false)) { while (indianPrairieCursor.MoveNext()) { using (Feature feature = (Feature)indianPrairieCursor.Current) { // Process the feature. For example... Console.WriteLine(feature.GetObjectID()); } } } } }); }
Target Platforms: Windows 11, Windows 10