I just tried to build some logic, where I split a server table with multiple topologies (points + lines + polygons) into three seperate layers, displaying these as layers in a LayerOverlay.
To do this, I add a where clause, selecting only the relevant geometry types for each layer. I use the OGC method STGeometryTYpe() for this, i.e.:
(layer).WhereClause = "where " + geoColnam + “.STGeometryType() In (‘Point’)”
(layer).WhereClause = "where " + geoColnam + “.STGeometryType() In (‘LineString’,‘MultiLineString’)”
(layer).WhereClause = "where " + geoColnam + “.STGeometryType() In (‘Polygon’,‘MultiPolygon’,‘GeometryCollection’)”
I get an error saying that the method “STGeometryType” isn’t found, even though a query with the exact same clause in Management Studio et.al. works perfectly.
Are there limitations to what kind of SQL one can use in the MsSql2008FeatureLayer where clauses ??
I view the code about WhereClause for MsSql2008FeatureLayer, it looks this part only did some validation and then directly append this part to SqlStatement and build SqlCommand based on that.
So I think that’s because SqlCommand(System.Data.SqlClient) class don’t support OGC method.
Then I did some research on how to make SqlCommand support OGC method but unlucky I haven’t found useful information. If you have any more information about this problem please let us know, we will keep enhancement MsSql2008FeatureLayer.
I’m sorry, but I’ll have to disagree with you on that assumption.
I created a small test script that just returned the number of individual topologies (points vs lines vs polygons) in a single MS/SQL-2008 table.
And it works very nicely, so the OGC methods are indeed available thru the SqlCommand interface:
Dim cmd As New SqlCommand("", conn)
Withcmd .CommandText = "select count(*) from vand where SP_GEOMETRY.STGeometryType() In (‘Point’)" lblCountPoints.Text = .ExecuteScalar().ToString EndWith Withcmd .CommandText = "select count(*) from vand where SP_GEOMETRY.STGeometryType() In (‘LineString’,‘MultiLineString’)" lblCountLines.Text = .ExecuteScalar().ToString EndWith Withcmd .CommandText = "select count(*) from vand where SP_GEOMETRY.STGeometryType() In (‘Polygon’,‘MultiPolygon’,‘GeometryCollection’)" lblCountPolygons.Text = .ExecuteScalar().ToString EndWith
The problem seems to be a bit more complex than you assume. You’ll need to dig a little deeper, I think.