0

I've included Microsoft.SqlServer.Types to enable the geography and geometry types in Entity Framework, but I don't see any functions equivalent to STContains().

I need to make a query to retrieve the geography that contains a point

In SQL I wrote like this:

SELECT adm1code, adm1name 
FROM Adm2GeoBoundaries
WHERE Coords.STContains(geography::Parse('POINT(-121.703796 46.893985)'));

in LINQ I expect to have something like

using (GeoEntities db = new GeoEntities ())
{
    DbGeography location = DbGeography.FromText("POINT(-121.703796 46.893985)");
    var admin = from a in db.Adm2GeoBoundaries
                where a.Coords.STContains(location)
                select a;
}

but a.Coords.STContains(location) throws an error

STContains method doesn't exist

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Giox
  • 4,785
  • 8
  • 38
  • 81

1 Answers1

0

According to the source code for EF6 Source Code, the STContains seems to be implemented as Contains in EF6.

https://github.com/aspnet/EntityFramework6/blob/master/src/EntityFramework.SqlServer/SqlSpatialServices.cs

enter image description here

Looking at the SqlTypesAssembly.cs you should be able see it should invoke the STContains method.

enter image description here

Dawood Awan
  • 7,051
  • 10
  • 56
  • 119