Is it possible to stop the request after the first condition is satisfied where?
where
I want to get only the first record, the time of which is longer than timeParameter. what i have now:
timeParameter
var records = from rec in table where rec.time > timeParameter select rec; return records.FirstOrDefault();
The time column in the database is sorted in ascending order, so with the first rule of the where clause there is no need to continue the queries. I have many rows in the database, so I want the request to be stopped as soon as possible.
. records IQueryable, , ( FirstOrDefault), .
records
, records LINQ, , SQL WILL. , . SQL (FirstOrDefault ) .
FirstOrDefault
, , order by, . ( DangerMonkey)
order by
from rec in table where rec.time > timeParameter order by rec.time select rec;
PS. , ,
, .
.FirstOrDefault(). SQL-, SELECT TOP 1 ..., , , SQL Server , , .
.FirstOrDefault()
SELECT TOP 1 ...
:
...
, ? , , , . , order by , , . , .
var records = from rec in table where rec.time > timeParameter order by rec.time select rec; return records.FirstOrDefault();