get a list of columns in an MapInfo source

Topics: Data Access, SharpMap v0.9 / v1.x
Jul 6, 2011 at 2:44 AM

Is it possible to get a list of all of the columns in a MapInfo source without having to retrieve all the data.

I can get the columns doing this...

 var results = provider.ExecuteQuery("SELECT * FROM " + layerName);

 var fields = results.Tables.First().Columns.Cast<DataColumn>().Select(c => new GISLayerField {Identifier = c.ColumnName, Description = c.ColumnName});

however it requires me to return all of the data in a layer. The datasources I have don't have any one common column so I couldn't filter on that column being equal to something.

Is there another way, perhaps some internal call in sharpmap that I could expose?

Jul 6, 2011 at 8:40 AM
Edited Jul 6, 2011 at 8:40 AM

Currently a "GetSchemaTable()" function is not implemented, however, you could try to

  • add a LIMIT 1 clause to your ExecuteQuery string (I don't know if that can be handled).
  • Call GetFeatureById(). The returned FeatureDataRow knows about the columns as well.
  • publicly expose the current ReadColumnDefinition( ) function

Hth FObermaier

Jul 7, 2011 at 3:50 PM

not sure if it works in mapinfo but it does in sql server : "select top 0 * from foo"


cheers jd