表连接查询

来源:互联网 发布:迅捷绑定mac地址 编辑:程序博客网 时间:2024/06/10 21:57
AE中查询主要的接口有IQueryFilter,ISpatialQuery,IQueryDef这三个接口。其中ISpatialQuery主要是空间查询。其中IQueryDef可以进行多表查询,IQueryDef.Table为要查询表的名称,多个表用,隔开。IQueryDef2接口继承于IQueryDef,并增加了PostfixClause属性,这个属性主要是用来排序的。例如ORDER BY Pop1996,另外还有个PrefixClause属性。主要用来定义DISTINCT这个关键字 ,更SQL中的一样。查询结果是只读的无法对其修改。
IQueryDef2 queryDef2 = (IQueryDef2)featureWorkspace.CreateQueryDef();// Specify the table and fields to query.queryDef2.Tables = "Cities";queryDef2.SubFields = "Name, Pop1996"; //注意PostfixClause中的字段必须出现在SubFields属性中 否则会报错queryDef2.PostfixClause = "ORDER BY Pop1996 DESC";// Execute the query.using (ComReleaser comReleaser = new ComReleaser()){  ICursor cursor = queryDef2.Evaluate2(true);  comReleaser.ManageLifetime(cursor);  int nameIndex = cursor.FindField("Name");  int pop1996Index = cursor.FindField("Pop1996");  IRow row = null;  while ((row = cursor.NextRow()) != null)  {    String cityName = Convert.ToString(row.get_Value(nameIndex));  //结果只读 无法修改    int population = Convert.ToInt32(row.get_Value(pop1996Index));    Console.WriteLine("{0}: {1}", cityName, population);  }}

0 0