小编ore*_*pan的帖子

如何在LINQ查询中调用本地函数?

我试过了:

 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)

c# linq asp.net function

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

asp.net ×1

c# ×1

function ×1

linq ×1