Hello, ThinkGeo Team!
Today I decided to torment you some questions about MsSql2008FeatureLayer. =)
Questions:
1) Why do so many requests going to the database? I have included MS SQL profiler and wondered why so many different requests goes to the database. Layer generates a query for each tile? The result is still quite a lot of requests, which are supposed to be combined into one.
2) How to use transactional?For example if I delete a set of objects at once?
________________________
Collection<feature> c_f = this.sql2008Layer.QueryTools.GetFeaturesIntersecting(this.wpfMap1.CurrentExtent, ReturningColumnsType.AllColumns);
this.sql2008Layer.EditTools.BeginTransaction();
foreach (var item in c_f)
{
this.sql2008Layer.EditTools.Delete(item.Id);
}
this.sql2008Layer.EditTools.CommitTransaction();</feature>
________________________
But in this situation it only removes the first item in the list and as a result of improperly constructing a database query. If I write
________________________
Collection<feature> c_f = this.sql2008Layer.QueryTools.GetFeaturesIntersecting(this.wpfMap1.CurrentExtent, ReturningColumnsType.AllColumns);
foreach (var item in c_f)
{
this.sql2008Layer.EditTools.BeginTransaction();
this.sql2008Layer.EditTools.Delete(item.Id);
this.sql2008Layer.EditTools.CommitTransaction();
}</feature>
________________________
In this case it works, but in this case, I get many requests to the database as the number of deleted objects, that is not quite logical, because if I want in a single transaction to delete these objects? And in most cases generated by the query again, may be the only one. What am I doing wrong?
My code below:
private void button1_Click(object sender, RoutedEventArgs e)
{
string connectString = @"Data Source=RND-137\DENALI;Initial Catalog=2GIS_TEST;Persist Security Info=True;Integrated Security=True;";
this.sql2008Layer = new MsSql2008FeatureLayer(connectString, "msk_house_test", "geom", 4326);
this.sql2008Layer.FeatureIdColumn = "ID";
this.sql2008Layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.SimpleColors.Red;
this.sql2008Layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay sql2008Overlay = new LayerOverlay();
sql2008Overlay.Layers.Add("Sql2008Layer", this.sql2008Layer);
sql2008Overlay.RenderMode = RenderMode.DrawingVisual;
wpfMap1.Overlays.Add("Sql2008Overlay", sql2008Overlay);
}
private void button2_Click(object sender, RoutedEventArgs e)
{
this.sql2008Layer.Open();
Collection<Feature> c_f = this.sql2008Layer.QueryTools.GetFeaturesIntersecting(this.wpfMap1.CurrentExtent, ReturningColumnsType.AllColumns);
foreach (var item in c_f)
{
this.sql2008Layer.EditTools.BeginTransaction();
this.sql2008Layer.EditTools.Delete(item.Id);
this.sql2008Layer.EditTools.CommitTransaction();
}
this.wpfMap1.Refresh();
}