我一个应用程序,我需要得到附近的地点工作最接近的位置, 我的web服务将接收2个参数(十进制经度,数字纬度)查找经度和纬度
我有一个表,其中位置被保存在经度和纬度字段的数据库中,
我想检索最近的位置。
任何人都可以帮忙吗?
这是我的代码:
var locations = from l in locations
select l
以下是有关这个进一步的细节: 我有一个2名的字段(十进制(18,2)空)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();
}
代码?非常简短......你有什么尝试过的吗? – lboshuizen