这两天写AE的查询,开始很顺利,后来当我使用单独的shape文件而不适用geodatabase的时候就会报错,上网发现是IQueryFilter的WhereClause写错了。网上解决的方法有些简单,不符合我的需求,于是自己查询了AE的帮助文档,发现了较好的解决方案。
文档的题目是
Querying geodatabase tables
http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/d/000100000146000000.htm
里面比较有用的是ISQLSyntax接口,使用的范例代码:
[C#] // Cast to the ISQLSyntax interface and get the supportedPredicates value. ISQLSyntax sqlSyntax = (ISQLSyntax)workspace; int supportedPredicates = sqlSyntax.GetSupportedPredicates(); // Cast the predicate value to an integer and use bitwise arithmetic to check for support. int predicateValue = (int)esriSQLPredicates.esriSQL_BETWEEN; int supportedValue = predicateValue & supportedPredicates; Boolean isSupported = supportedValue > 0;
[VB.NET] ' Cast to the ISQLSyntax interface and get the supportedPredicates value. Dim sqlSyntax As ISQLSyntax = CType(workspace, ISQLSyntax) Dim supportedPredicates As Integer = sqlSyntax.GetSupportedPredicates() ' Cast the predicate value to an integer and use bitwise arithmetic to check for support. Dim predicateValue As Integer = CInt(esriSQLPredicates.esriSQL_BETWEEN) Dim supportedValue As Integer = predicateValue And supportedPredicates Dim isSupported As Boolean = supportedValue > 0