ThinkGeo.com    |     Documentation    |     Premium Support

Looking for API 2.0 equivalent: DataQuery

Hello,


Still porting our application from 2.0 => 3.0, we cannot found any equivalent for this line:


DataTable ret = Layer.DataQuery(feature.RecordNumber, false);


Starting from a feature, we need to get a "DataTable" that contains the data columns.


Of course, we could find lot of api that retreive the data, but not with the good "datatable" type.


Any ideas ?


Patrick.


 



Patrick, 


In our current 3.x version APIs, we will only return back Datatable for SQL statement like this:

worldLayer.Open(); 
DataTable dataTable = worldLayer.QueryTools .ExecuteQuery(tbxSQL.Text);
worldLayer.Close();

For other APIs, we will return collection of Features from which we will have more controls and flexibility. Following is the sample code you can create a DataTable based on the features returned back:



private static DataTable GetDataTable(Collection<Feature> features)
{
  DataTable dataTable = new DataTable("FeatureDataTable");

  if (features.Count > 0)
  {
     foreach (string columnName in features[0].ColumnValues.Keys)
     {
        if (!dataTable.Columns.Contains(columnName))
        {
           dataTable.Columns.Add(columnName);
        }
     }
  }

  foreach (Feature feature in features)
  {
     dataTable.Rows.Add(feature.ColumnValues.Values);
  }

  return dataTable;
}

Any more questions just let me know.


Yale