How can I write a query similar to this one in LINQ to SQL
SELECT Id, (Distance - someValue) as Res
FROM Table
WHERE Res < someOtherValue
ORDER BY Res
How can I write a query similar to this one in LINQ to SQL
SELECT Id, (Distance - someValue) as Res
FROM Table
WHERE Res < someOtherValue
ORDER BY Res
MyTable
.Where(m => m.Res < 4)
.OrderBy(m => m.Res)
.Select(m => new {Id, Res = m.Distance - 4});
...where 4 is your someOtherValue
If you prefer keyword-style LINQ, it'd look something like this:
from x in theTable
where x.Distance < someOtherValue + someValue
orderby x.Distance
select new { x.Id, Res = x.Distance - someValue }