Hello,
I have the countries02.shp file represented on SQL server table. I want to query over this file and display colored layer for countries with certain attributes.
This piece of code:
string connectString = "Data Source=Victor-PC\\SQLEXPRESS;Initial Catalog=Spatial;User Id=vicas;Password=123;";
MsSql2008FeatureLayer sql2008Layer = new MsSql2008FeatureLayer(connectString, "dbo.Countries02", "ID");
sql2008Layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
sql2008Layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
sql2008Layer.Srid = 4326;
sql2008Layer.CustomGeometryColumnName = "geom";
sql2008Layer.Open();
DataTable allFeatures1 = sql2008Layer.QueryTools.ExecuteQuery("SELECT * FROM Countries02 where POP_CNTRY>10000 ");
return datatable called allFeatures1 that contains rows of countries that have population > 10000.
The other piece of code:
string connectString = "Data Source=Victor-PC\\SQLEXPRESS;Initial Catalog=Spatial;User Id=vicas;Password=123;";
MsSql2008FeatureLayer sql2008Layer = new MsSql2008FeatureLayer(connectString, "dbo.Countries02", "ID");
sql2008Layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
sql2008Layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
sql2008Layer.Srid = 4326;
sql2008Layer.CustomGeometryColumnName = "geom";
sql2008Layer.Open();
Collection<Feature> allFeatures = sql2008Layer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns);
returns a collection of features that contains all conutries data.
I can make my query on this collection but I see this a bad way to make my query. The other way of make my query is the query using Sql statement and return datatable then
transform this datatable to Collection<Feature> which can be easily add to layer/layers with one or more colors.
My question is that I need a way to transform from datatable to collection<feature>. I searched the web and I found no working example. I need a working example for that please.
Thanks in advanced,
Victor