我正在开发一个需要获取附近位置的应用程序,我的网络服务将接收 2 个参数(十进制经度,十进制纬度)
我有一个表格,其中位置保存在带有经度和纬度字段的数据库中,
我想检索最近的位置。
任何人都可以帮忙吗?
这是我的代码:
var locations = from l in locations
select l
以下是有关此的更多详细信息:我在数据库表中有 2 个字段(decimal(18, 2) null)1 个纬度,2 个经度,
我有一个方法
public List<Locations> GetLocation(decimal? Long, decimal? lat)
{
var Loc = from l in Locations
//// now here is how to get nearest location ? how to query?
//// i have also tried Math.Abs(l.Lat - lat) its giving error about nullable decimal always hence i have seted decimal to nullable or converted to nullable
//// also i have tried where (l.lat - Lat) * (l.lon - Long) this is also giving error about can not convert decimal to bool
return Loc.ToList();
}