我正在尝试计算用户当前点与数据库中另一个点的距离。我写了以下代码,但出现function st_x(geography) does not exist
错误。
var pointsQueryable = _context.Points;
var points = pointsQueryable.Select(x => new PointViewModel
{
Id = x.Id,
Title = x.Title,
Address = x.Address,
Description = x.Description,
Longitude = x.Location.X,
Latitude = x.Location.Y,
Image = x.Image,
DistanceFromUser = x.Location.Distance(new Point(filter.UserLongitude, filter.UserLatitude)),
});
当然,我已经用CREATE EXTENSION postgis;
命令为数据库启用了postgis。