AO查询过程中对结果进行排序

        在AO中查询,通常用Search方法,传入一个IQueryFilter类型的变量,但其只有一个Whereclause可选,要对查询结果按照某列排序的话还需要用IQueryDefinition接口。一个例子:
IQueryFilter pQF = new QueryFilterClass();
IQueryFilterDefinition queryFilterDef = (IQueryFilterDefinition)pQF;
queryFilterDef.PostfixClause = "ORDER BY " + (axMapControl1.get_Layer(0) as IFeatureLayer).DisplayField;
IFeatureCursor pFeatureCursor = pFC.Search(pQF, true);//pFC,featureclass

        还需要注意一点,此属性不适用与FileGDB:Please note, file geodatabases do not support the PostFixClause property, and any specifications within the PostFixClause will be ignored。
        结果curcor里面的feature就已经按照displayfield排好序了。另外,如果要对已有表进行排序的话可以使用ITableSort接口。

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>