1

I am trying to find the stores within X radius of a users lat & long. I have read quite a few questions, answers, and articles on the topic. My results don't have to be pin point accurate but false positives as you might get with the filter on a Geography column would not be acceptable.

Given the above requirements I don't see the need to use the Geography data type and add a spatial index. I also don't need a perfect circle radius. In other words a bounding box would be acceptable. So I settled on this solution from Alastaira who has a very informative session on the topic here.

Now my application is MVC using CF EF4 and SQL 2008R2. I was originally thinking to do the operation in LINQ like I would any other db interaction but I was honestly stumped at a few steps such as:

DECLARE @point geography = geography::Point(40.7316, -73.9920, 4326);

I don't think EF4 supports the geography data type so that would certainly complicate things.

Then I started thinking...given that the db is kinda geared for this kind of crunching should I just wrap the TSQL in a SP that spits out a recordset I can then use LINQ on?

This is my first spatial db operation so any ideas or suggestions are welcome and would be appreciated.

If the sp is a viable solution suggestions for the best way to implement would be great.

tereško
  • 58,060
  • 25
  • 98
  • 150
GPGVM
  • 5,515
  • 10
  • 56
  • 97

1 Answers1

1

I don't think EF4 supports the geography data type so that would certainly complicate things.

Entity Framework 4.x does not natively support geography.

If the sp is a viable solution suggestions for the best way to implement would be great.

Using stored procedures to return stronly typed objects has already been asked. It should be straight forward enough to create a stored procedure to deal with the geography datatype but not include that specific type in the result entity objects.

Community
  • 1
  • 1
Erik Philips
  • 53,428
  • 11
  • 128
  • 150