Hi Steph,
Your explanation is very clear.
1), yes, we fixed this bug before and it will take the first enable one.
2), In this case, mssqlfeaturelayer2 would not use the special index 2 which built for geometry2 by automatically. This is because we don’t know what’s the mapping between the index name and the geometry name. But there is a workaround I think: We can register the ExecutingSqlStatement event and modify the special index name based the layer name before execute the query on the sql server side. Some codes would be like the below:
sql2008Layer.Open();
((MsSql2008FeatureSource)sql2008Layer.FeatureSource).ExecutingSqlStatement += LoadMsSql2008FeatureLayer_ExecutingSqlStatement;
void
LoadMsSql2008FeatureLayer_ExecutingSqlStatement(
object
sender, ExecutingSqlStatementMsSql2008FeatureSourceEventArgs e)
{
string
statement = e.SqlStatement;
if
(statement.IndexOf(
" with(index("
) > 0)
{
// replace the index name
}
e.SqlStatement = statement;
}
Here is a statement template: SELECT [geom].STAsBinary() as [geom],[ID] FROM cntry02 with(index(
SPATIAL_cntry02)) WHERE (geometry::STGeomFromWKB(
@Geometry,4326).STIntersects(geom)=1);
Btw, please make sure the special index 2 is enable or the index won’t take effect.
Any questions, please feel free to let us know.
Thanks,
Troy