Get a location, save it to a DB, search against it

David Thielen 2,796 Reputation points
2023-03-05T01:47:22.67+00:00

Hi all;

This is a 4 part question that I think crosses several parts. Here goes. I need to do the following:

  1. Feed in an entered address and get back the correct address (or a "can't find it".
  2. From that address get the location of that address.
  3. Save that location using EntityFrameworks into the underlying SQL Database.
  4. Search the database for all users within N miles of a specified location.

I've found a ton of stuff on this searching the web - none of which works. I can't even find a class to store the location that I can find a matching library for. So help please.

thanks - dave

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,649 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 61,731 Reputation points
    2023-03-06T16:59:23.99+00:00
    1. to standardize and verify address, you will need to subscribe to a service or buy a database (with updates) to do this.
    2. be sure to pick a vendor that supplies the geo location of the address
    3. use spatial datatype. see:

    https://learn.microsoft.com/en-us/sql/t-sql/spatial-geography/spatial-types-geography?view=sql-server-ver16

    https://learn.microsoft.com/en-us/ef/core/modeling/spatial

    1. use the STDistance to calc distance. see above docs