Select to view content in your preferred language

QueryFilter PostFix Clause Not Working With Shapefiles

628
2
Jump to solution
10-27-2023 03:47 PM
estz2
by
Emerging Contributor

Hi all, first post here so let me know if I filled this out wrong.

I am working on an add-in that uses the postfix clause of a queryfilter to order the results. I ran into a bug where a feature layer sourced from a shapefile doesnt sort correctly or at all (just returns rows in order of object id when my postfix was for a different column ascending). When I saved the same feature layer to a geodatabase and added it back into the project, the postfix clause worked just as expected (sorted correctly).

Here was the code block in question:

var queryFilter = new QueryFilter
{
    WhereClause = $"{treeLayerInfoFields["objectid"]} IN ({string.Join(",", batch)})",
    PostfixClause = $"ORDER BY {treeLayerInfoFields["dbh_in"]} ASC",
};


Has anyone else ran into shapefile-sourced feature layers not working when querying with a postfix clause?

Thanks!

0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi,

Shapefiles have some limitations. 

DISTINCT, ORDER BY, and ALL are only supported when working with databases. They are not supported by other data sources (such as dBASE or INFO tables).

SearchCursor—ArcGIS Pro | Documentation

You could try to use Table method Sort.

View solution in original post

2 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

Shapefiles have some limitations. 

DISTINCT, ORDER BY, and ALL are only supported when working with databases. They are not supported by other data sources (such as dBASE or INFO tables).

SearchCursor—ArcGIS Pro | Documentation

You could try to use Table method Sort.

estz2
by
Emerging Contributor

Thank you!

0 Kudos