我试过了:
var doctorPractise = from d in db.DoctorsPrivateClinics
where GetDistance(db, d)<1.0
select d;
Run Code Online (Sandbox Code Playgroud)
但这不起作用,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 = …Run Code Online (Sandbox Code Playgroud)