我试过了:
var doctorPractise = from d in db.DoctorsPrivateClinics where GetDistance(db,d)<1.0 select d;
但这不起作用,GetDistance是一个本地函数,我没有得到一个例外但它似乎没有工作,任何想法?
谢谢
GetDistance是:
private double GetDistance(DBClassesDataContext db,DoctorsPrivateClinic docPra) { double distance=-1; double longitude; double latitude; var city = from c in db.Cities where c.Code == Convert.ToInt32(Request.QueryString["Area"]) select c; foreach (var cit in city)//it will be just one row that will be found but I don't know how to express it without foreach { Calculations.GetLongitudeLatitudeGoogle getLongLat = new Calculations.GetLongitudeLatitudeGoogle(); getLongLat.GetLongitudeLatitude("",cit.Name,"",out longitude,out latitude); distance = CalcualateDistance(Convert.ToDouble(docPra.PrivateClinic.Latitude),Convert.ToDouble(docPra.PrivateClinic.Longtitude),latitude,longitude); } return distance; }
我想要实现的是计算地图上某个特定点(cit.Name)与私人诊所的位置之间的距离.已从Google地图中检索地图上特定点的经度和纬度.在我的查询中,我指定此距离必须小于1公里