How to make this query with DefinitionQuery

Topics: Data Access
Jun 29, 2012 at 10:12 AM

Hello all, i need to make a query by definitionQuery:

 

select p.the_geom from ccpp as c, tramo as p where st_contains(c.the_geom,p.the_geom)=true and cod_postal= '28081'

 

I know how to make a simple query like:

string query = "\"cod_postal\" IN ('28081')";

This works ok, but i can´t make the query before, any help??

 

Thanks a lot.

Coordinator
Jun 29, 2012 at 11:31 AM

You need to create a spatial view on your database to do such things. Which provider are you using?

Jun 29, 2012 at 3:16 PM

I`m using POSTGIS provider, there´s no way to do it with:

provider = new SharpMap.Data.Providers.PostGIS(connectionString, "tramo", "the_geom", "4326");

provider.DefinitionQuery = "select p.the_geom from ccpp as c, tramo as p where st_contains(c.the_geom,p.the_geom)=true and cod_postal= '28081'";

myLayer.DataSource = provider;

Thanks.

Developer
Jun 30, 2012 at 1:51 AM
Edited Jun 30, 2012 at 2:05 AM

provider.DefinitionQuery= provider.ObjectIdColumn+ " in ( select p."+ provider.ObjectIdColumn +"  from ccpp as c, tramo as p where st_contains(c.the_geom,p.the_geom)=true and cod_postal= '28081'");