Friday, September 23, 2011

This post is an object

This post has been instantiated and so its an object now. I think.

I have been focusing on learning ArcObjects on .NET via C# the last couple weeks and the last few days I finally feel like I am starting to get it. I think the key has been grasping the Object Oriented approach. These articles are what really got be moving with that.They are pretty generic and quick to get through, which helps me.
http://www.developer.com/lang/article.php/3628381/The-Object-Oriented-Thought-Process-Index-Page.htm

As for C# in particular this series has helped me get a grasp on the basics.
http://msdn.microsoft.com/en-us/beginner/bb308730.aspx

Other than that I want to start posting something useful so...

I found that the ArcObject IQuerDef2 only allows "advanced" SQL queries on SDE databases... or at least not on file geodatabases. For example, the following works on an SDE but not File geodatabase.


 IFeatureWorkspace featureWorkspace = workspace;
            IQueryDef2 queryDef = (IQueryDef2)featureWorkspace.CreateQueryDef();
            queryDef.Tables = inTable;
            queryDef.PrefixClause = "TOP (29)"; 
            queryDef.SubFields = field + ", COUNT(*)";
            queryDef.PostfixClause = "GROUP BY " + field + " ORDER BY COUNT(*) DESC, " + field; 
            queryDef.WhereClause = field + "!= ''"; 

I never found this documented anywhere but after testing a ton of queries on both sources its clear.

Maybe someday there will be an IQuerDefX that will support it. Or maybe it will come down to the File GDB format since the SQL probably gets thrown to the database anyways.

No comments:

Post a Comment