Nuget:Npgsql.EntityFrameworkCore.PostgreSQL.Net TopologySuite
The Entity
Using NetTopologySuite. Geometries';
Public break {
Public string Name {get; The set; }
Public string {feel get; The set; }
Public string Phone {get; The set; }
Public Point Location {get; The set; }
}
Dbcontext
Protected override void OnConfiguring (DbContextOptionsBuilder builder)
{
Builder. UseNpgsql (" Host=localhost; The Database=test; The Username=npgsql_tests; Password=npgsql_tests ",
O=& gt; O.U seNetTopologySuite ());
}
Protected override void OnModelCreating (ModelBuilder builder)
{
Postgis builder. HasPostgresExtension (" ");
}
Query the location in the PGSQL type: point value "(106.2889702, 31.2832916)"
Var currentLocation=new Point (106.2972496, 31.2669647) {4326} SRID=;
Var data=https://bbs.csdn.net/topics/_dbContext.Merchant.Where (x=> x.L ocation. Short (currentLocation) <100). ToList ();
The following error: PostGIS installed
CodePudding user response:
The function st_distance does not exist, the database version does not support this functionCodePudding user response:
PostGIS installedCodePudding user response:
Error obviouslyThe function the st_distance (point, geography) does not exist
CodePudding user response: