public FeatureQueryExpression(AttributesProjectionExpression attributes,
                               AttributesPredicateExpression attributeFilter,
                               SpatialBinaryExpression spatialFilter, SortExpressionCollectionExpression sort)
     : base(attributes, new BinaryExpression(attributeFilter,
                                             BinaryOperator.And,
                                             spatialFilter), sort)
 {
 }
 public FeatureQueryExpression(AttributesProjectionExpression attributes,
                               AttributeBinaryExpression attributeFilter,
                               SpatialBinaryExpression spatialFilter)
     : base(attributes, new BinaryExpression(attributeFilter,
                                             BinaryOperator.And,
                                             spatialFilter))
 {
 }
        public void T11_JD_Test()
        {
            //return;
            var search = new SpatiaLite2Provider(_geometryFactory,
                                                  @"Data Source=C:\VENUS\CodePlex\sharpMap\SharpMap\TestData\VRS2386_V11.sqlite", "main",
                                                  "regions", "OID", "XGeometryX");

            //search.SpatiaLiteIndexType = SpatiaLite2_IndexType.MBRCache;

            var binaryExpression =
                new BinaryExpression(new PropertyNameExpression("VHG5"),
                                     BinaryOperator.GreaterThan, new LiteralExpression<int>(6));

            var columns = new string[] { "Einwohner" };

            search.DefaultProviderProperties = 
                new ProviderPropertiesExpression(
                        new ProviderPropertyExpression[] { new AttributesCollectionExpression( columns ) }
                    );

            var prov = new ProviderQueryExpression(
                (ProviderPropertiesExpression)null, 
                new AllAttributesExpression(), 
                binaryExpression);

            object obj = search.ExecuteQuery(prov);

            Assert.IsNotNull(obj);
            SharpMap.Data.Providers.Db.SpatialDbFeatureDataReader sfdr = obj as SharpMap.Data.Providers.Db.SpatialDbFeatureDataReader;
            Assert.IsNotNull(sfdr);
            Int64 numRows = 0;

            DateTime start = DateTime.Now;
            while (sfdr.Read())
                numRows++;
            DateTime end = DateTime.Now;
            System.Diagnostics.Debug.WriteLine(end.Subtract(start).ToString());

            search.DefaultProviderProperties = null;

            obj = search.ExecuteQuery(prov);
            sfdr = obj as SharpMap.Data.Providers.Db.SpatialDbFeatureDataReader;
            Assert.IsTrue(numRows > 1);
            start = DateTime.Now;
            while (sfdr.Read())
                numRows++;
            end = DateTime.Now;
            System.Diagnostics.Debug.WriteLine(end.Subtract(start).ToString());

            var providerProps =
                new ProviderPropertiesExpression(
                    new ProviderPropertyExpression[]
                        {
                            new OrderByCollectionExpression(
                                new OrderByExpression("Einwohner", System.Data.SqlClient.SortOrder.Descending)),
                            new DataPageSizeExpression(10),
                            new DataPageNumberExpression(5) 

                        });
            var ape = new AttributesProjectionExpression(new String[]{"OID" ,"Einwohner", "Erwerbstätige", "Beschäftigte"});

            prov = new ProviderQueryExpression(providerProps, ape, null);

            sfdr = search.ExecuteQuery(prov) as SharpMap.Data.Providers.Db.SpatialDbFeatureDataReader;
            Assert.IsNotNull(sfdr);
            numRows = 0;
            while (sfdr.Read()) numRows++;
            Assert.AreEqual(10, numRows);
            Assert.AreEqual(4, sfdr.FieldCount);
        }
        public void T11_JD_Test()
        {
            PostGisProvider<int> search = new PostGisProvider<Int32>(_geometryFactory,
                                                                     connectionString, "public",
                                                                     "vw_osm_germany_line", "osm_id", "way");

            BinaryExpression binaryExpression =
                new BinaryExpression(new PropertyNameExpression("z_order"),
                                     BinaryOperator.Equals, new LiteralExpression<int>(0));

            ProviderPropertiesExpression providerProps =
                new ProviderPropertiesExpression(
                    new ProviderPropertyExpression[] {});


            ProviderQueryExpression prov = new ProviderQueryExpression(null as ProviderPropertiesExpression,
                                                                       new AllAttributesExpression(), binaryExpression);

            object obj = search.ExecuteQuery(prov);

            Assert.IsNotNull(obj);
            PostGisFeatureDataReader sfdr = obj as PostGisFeatureDataReader;
            Assert.IsNotNull(sfdr);
            Int64 numRows = 0;
            while (sfdr.Read())
                numRows++;
            Assert.IsTrue(numRows > 1);

            providerProps =
                new ProviderPropertiesExpression(
                    new ProviderPropertyExpression[]
                        {
                            //new OrderByCollectionExpression(
                            //    new OrderByExpression("z_order", SortOrder.Descending)),
                            new DataPageSizeExpression(10),
                            new DataPageNumberExpression(5)
                        });
            AttributesProjectionExpression ape =
                new AttributesProjectionExpression(new[] {"osm_id", "name", "z_order", "way"});

            prov = new ProviderQueryExpression(providerProps, ape, null);

            sfdr = search.ExecuteQuery(prov) as PostGisFeatureDataReader;
            Assert.IsNotNull(sfdr);
            numRows = 0;
            while (sfdr.Read()) numRows++;
            Assert.AreEqual(10, numRows);
            Debug.WriteLine("\r\n*** T11 passed!");
        }