如何在LINQ to SQL
中编写类似于此查询的查询SELECT Id, (Distance - someValue) as Res
FROM Table
WHERE Res < someOtherValue
ORDER BY Res
答案 0 :(得分:2)
如果您更喜欢关键字式LINQ,它看起来像这样:
from x in theTable
where x.Distance < someOtherValue + someValue
orderby x.Distance
select new { x.Id, Res = x.Distance - someValue }
答案 1 :(得分:1)
MyTable
.Where(m => m.Res < 4)
.OrderBy(m => m.Res)
.Select(m => new {Id, Res = m.Distance - 4});
...其中4是你的someOtherValue