DataTableProvider

Topics: Data Access, SharpMap v0.9 / v1.x, SharpMap v2.0
May 28, 2008 at 2:14 PM
Hello,
I would like to combine some data sources (mssql + datagrid) so usage of a DataTableProvider seemed to be good choice.
However I use a 0.9 release and DataTableProvider class seems a bit strange to me. Sorry, no idea what is it good for. I assume that there should be some constructor and members of DataTable type.
OK. I tried to try SharpMap 2 version, because its DataTableProvider looked much more better, downloaded source code from http://sharpmapv2.googlecode.com/svn/trunk along with other necessary projects, add GeoAPI project reference, but I am not still able to compile the project. It seems that GeoAPI.Coordinates was changed to GeoAPI.CoordinateSystems namespace.

So, the questions are:
1) is there any DataTableProvider for 0.9 release witch is able to use System.Data.DataTable as a data source
2) is there any SharpMap 2 version which is easy to compile. If I want to put focus on improving some parts I am not sure it is conductive to spent a time by renaming references and so on.

Thank you for your experience

Jirka Nouza
Coordinator
May 28, 2008 at 2:59 PM
Hi Jirka, you should be able to bind a FeatureDataset to a grid.. Use your chosen provider (MsSql provider) to fill a new FeatureDataset and bind that as you would a normal dataset HTH jd
Coordinator
May 29, 2008 at 6:36 AM
Hi Jirka,

GeoAPI.Coordinates and GeoAPI.CoordinateSystems both exist.

I've updated the Building SharpMap v2.0 page with updated info on how to build v2.0. You should find a fairly easy process at this point. If you attempt it and have any problems, let me know.
Jun 18, 2008 at 12:14 PM
Hi John,
thank you for your quick answer and I apologize for my long delay.

I can get FeatureDataSet, which is child of DataSet and bind it to a DataGridView. I assume, it is one way only. However, I want to render graphic according to values e.g. changed by a user, from completely different datasource. So I need to set some DataTable to some IProvider.

I had an idea to inherit FeatureDataRow and FeatureDataTable including poiters to one or more other DataTables containing user defined data or data from different data source. When was called a column name or index not existing in a FeatureDataRow, there was a handler looking into DataSets collection using primary key and return value from a DataSet. The problem is that it is not posible to override DataRow indexer, it is not virtual.
I am doing it in this way in my CustomRenderer, however, it is not a good idea to have this logic in a GetStyle() method:
public SharpMap.Styles.IStyle GetStyle(SharpMap.Data.FeatureDataRow dr)
{
   double decisionValue;
   bool decisionValueOK = false;
   if ((dr.Table.Columns.IndexOf(_lookupfield) < 0) || customDataTable != null)
   { // read data from custom data table
       if (double.TryParse(customDataTable.GetValue(int.Parse( dr["PrimaryKey"].ToString()), _lookupfield).ToString(), out decisionValue))
           decisionValueOK = true;
   }
   else  // read data from FeatureDataRaw
       if (double.TryParse(dr[_lookupfield].ToString(), out decisionValue))
           decisionValueOK = true;

So, it still seems to me, it will be easiest way to write a DataTableProvider : IProvider. I can send it here when I finish it.

Jirka