Cannot cast between QueryFilter and SpatialQueryFilter

548
1
07-26-2016 05:15 AM
ShaneBuscher
Occasional Contributor

I'm trying to cast from a SpatialQueryFilter up to a QueryFilter:

var spatialQueryFilter = new SpatialQueryFilter();

QueryFilter queryFilter = spatialQueryFilter;

However, the result type of the implicit cast for queryFilter is still SpatialQueryFilter.  Casting (explicitly) the other way around does not work either.

Ultimately I want to pass either a QueryFilter or its SpatialQueryFilter subclass into FeatureLayer.FeatureTable.QueyAsync(QueryFilter).  Without being able to cast a SpatialQueryFilter to a QueryFilter, QueryAsync always returns no results because the Geometry property is null. I understand there are workarounds for this, but am wondering why the casts aren't working?

0 Kudos
1 Reply
ShaneBuscher
Occasional Contributor

A coworker pointed out that the SDK may have defined an implicit type conversion on the SpatialQueryFilter class.  See implicit (C# Reference).​ If so, the properties of SpatialQueryFilter would persist when cast to QueryFilter, according the reference. Is this correct (ESRI)? 

0 Kudos