Skip to content

Instantly share code, notes, and snippets.

@alamsal
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alamsal/4a3987cbb857f0635e91 to your computer and use it in GitHub Desktop.
Save alamsal/4a3987cbb857f0635e91 to your computer and use it in GitHub Desktop.
Query personal gdb using ORDER BY and DISTINCT clause
public ICursor QueryRowViaQueryDef(IFeatureWorkspace featureWorkspace, String tables, String subFields, String whereClause)
{
// Create the query definition.
IQueryDef2 queryDef = featureWorkspace.CreateQueryDef() as IQueryDef2;
// Provide a list of table(s) to join.
queryDef.Tables = tables;
// Declare the subfields to retrieve.
queryDef.SubFields = subFields;
// Assign a where clause to filter the results.
queryDef.WhereClause = whereClause;
queryDef.PrefixClause = "DISTINCT";
queryDef.PostfixClause = "ORDER BY "+subFields+" ASC";
// Evaluate queryDef to execute a database query and return a cursor to the application.
ICursor cursor = queryDef.Evaluate();
return cursor;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment