Beispiel #1
0
        public void DbQuery_SelectMany_with_TVFs_and_spatial_types_using_Point_in_function_import_works()
        {
            using (var context = new SpatialNorthwindContext(_connectionString))
            {
                context.Database.Initialize(force: false);

                var results =
                    (from s1 in
                     context.SuppliersWithinRangeUsingPoint(
                         1000,
                         DbGeography.FromText(
                             "POINT(-122.335576 47.610676)",
                             4326))
                     from s2 in
                     context.SuppliersWithinRangeUsingPoint(
                         1000,
                         DbGeography.FromText(
                             "POINT(-122.335576 47.610676)",
                             4326))
                     where s1.Name == s2.Name
                     select new
                {
                    s1,
                    s2
                }).ToList();

                Assert.Equal(16, results.Count);
            }
        }
Beispiel #2
0
 public void Can_query_for_strongly_typed_geographic_point_using_type_construction()
 {
     using (var context = new SpatialNorthwindContext(_connectionString))
     {
         var query =
             @"select value ProductivityApiTests.SupplierWithLocation(-77, N'MyName', Edm.GeographyFromText(""POINT(-122.335576 47.610676)"")) 
                       from [SpatialNorthwindContext].[Suppliers] as SupplierWithLocation";
         Assert.Equal(16, TestWithReader(context, query, r => Assert.IsType <DbGeography>(r.GetValue(2))));
     }
 }
Beispiel #3
0
 public void Can_query_for_strongly_typed_geometric_point_using_complex_type_type_construction()
 {
     using (var context = new SpatialNorthwindContext(_connectionString))
     {
         var query =
             @"select value ProductivityApiTests.ComplexWithGeometry(N'A', Edm.GeometryFromText(""POINT(-122.335576 47.610676)"")) 
                       from [SpatialNorthwindContext].[Widgets] as WidgetWithGeometry";
         Assert.Equal(
             4, TestWithReader(
                 context, query, r =>
         {
             Assert.Equal("A", r.GetString(0));
             Assert.IsType <DbGeometry>(r.GetValue(1));
         }));
     }
 }
Beispiel #4
0
        private void DbQuery_with_TVFs_mapped_to_arbitrary_instance_methods_involving_spatial_types_works(
            Func <IQueryable <IQueryable <SupplierWithLocation> >, List <IQueryable <SupplierWithLocation> > > toList)
        {
            using (var context = new SpatialNorthwindContext(_connectionString))
            {
                var suppliers = (from x in context.Suppliers
                                 select
                                 ArbitrarySuppliersWithinRange(
                                     1000,
                                     DbGeography.FromText(
                                         "POINT(-122.335576 47.610676)",
                                         4326))).ToList();

                Assert.Equal(16, suppliers.Count);
            }
        }
Beispiel #5
0
        Can_materialize_record_containing_geographic_types_and_get_names_of_the_types_without_null_arg_exception(
            Func <IQueryable <DbDataRecord>, List <DbDataRecord> > toList)
        {
            using (var context = new SpatialNorthwindContext(_connectionString))
            {
                var query =
                    @"select o.[Location]
                              from [SpatialNorthwindContext].[Suppliers] as [o]";

                var results = ExecuteESqlQuery(context, query, toList);

                Assert.Equal(16, results.Count);
                foreach (var result in results)
                {
                    Assert.Equal("Location", result.GetName(0)); // GetName would throw
                    Assert.Same(typeof(DbGeography), result.GetFieldType(0));
                }
            }
        }
Beispiel #6
0
        public void DbQuery_SelectMany_with_TVFs_and_spatial_types_works()
        {
            using (var context = new SpatialNorthwindContext(_connectionString))
            {
                var results =
                    (from s1 in
                     context.SuppliersWithinRange(1000, DbGeography.FromText("POINT(-122.335576 47.610676)", 4326))
                     from s2 in
                     context.SuppliersWithinRange(1000, DbGeography.FromText("POINT(-122.335576 47.610676)", 4326))
                     where s1.Name == s2.Name
                     select new
                {
                    s1,
                    s2
                }).ToList();

                Assert.Equal(16, results.Count);
            }
        }
Beispiel #7
0
        Can_materialize_record_containing_geometric_types_and_get_names_of_the_types_without_null_arg_exception(
            Func <IQueryable <DbDataRecord>, List <DbDataRecord> > toList)
        {
            using (var context = new SpatialNorthwindContext(_connectionString))
            {
                var query =
                    @"(select o.[AGeometricLineString], 
                                      i.[AGeometricPolygon]
                               from [SpatialNorthwindContext].[LineStringWidgets] as [o]
                               left outer join [SpatialNorthwindContext].[PolygonWidgets] as [i]
                               on Edm.SpatialCrosses(o.[AGeometricLineString],i.[AGeometricPolygon]))";

                var results = ExecuteESqlQuery(context, query, toList);

                Assert.Equal(2, results.Count);
                foreach (var result in results)
                {
                    Assert.Equal("AGeometricLineString", result.GetName(0)); // GetName would throw
                    Assert.Equal("AGeometricPolygon", result.GetName(1));
                    Assert.Same(typeof(DbGeometry), result.GetFieldType(0));
                    Assert.Same(typeof(DbGeometry), result.GetFieldType(1));
                }
            }
        }