如何删除linq-to-entity语句中的“半径”,以使搜索范围不限于半径?
FYI-我希望查询以'term'开头的名称,并以与位置点最近的名称开头的向外搜索,但不限于半径
DbGeography location = DbGeography.FromText("POINT(" + longitude.ToString() + " " + latitude.ToString() + ")");
int radius = (50 * 5280); // 50 miles
var namesList = (from N in dbContext.Profiles
where N.FullName.StartsWith(term)
&& N.LocationPoints.Distance(location) <= radius
orderby N.LocationPoints.Distance(location) ascending
select new ProfileNameSearch {
label = N.FullName + " - " + N.Location,
value = N.FullName,
location = N.LocationPoints.Latitude.ToString() + "," + N.LocationPoints.Longitude.ToString()
}).Take(10).ToList();
答案 0 :(得分:0)
只需删除行
&& N.LocationPoints.Distance(location)<=半径