0

我使用 LINQ 搜索此查询的等效项:

SELECT  *
FROM Shapes
ORDER BY ABS(45.403703 - Latitude), ABS(- 71.948638 - Longitude)

有人有想法吗?我从 linq 开始

4

2 回答 2

2

像这样的东西?

var result = shapes
    .OrderBy(s => Math.Abs(45.403703 - s.Latitude))
    .ThenBy(s => Math.Abs(-71.948638 - s.Longitude));
于 2012-07-12T02:36:27.823 回答
0
    var results = 
    from x in shapes 
    orderby Math.Abs(45.403703 - x.Latitude),
            Math.Abs(- 71.948638 - x.Longitude)
    select x; 
于 2012-07-12T02:38:44.230 回答