2
I have a query where I make a query between 2 date ranges.
On those dates, I apply the DbFunctions.TruncateTime
to filter searches only by dates, ignoring the time.
Obs: are fields Datetime
.Where(p => DbFunctions.TruncateTime(p.DataCadastro) >= DbFunctions.TruncateTime(dataInicial) &&
DbFunctions.TruncateTime(p.DataCadastro) <= DbFunctions.TruncateTime(dataFinal));
However, when using the DbFunctions.TruncateTime
the request always returns to me:
Run Time Out. The time limit has expired before completion of the operation or the server is not responding.
Timeout usually indicates a valid query. Does your table have many records? It has index in this date field?
– Pagotti
When I do the same query without Truncatetime, I can do the queries. However, because it is Datetime, some records stop coming in this list.
– user108720
These functions are mapped internally on each provider to other functions and it may be that this is slowing down enough to give the timeout. Already tried to use the start date with time "00:00:00" and the end with time "23:59:59" and compare directly instead of truncating the field Date Registration for Date?
– Pagotti
@Pagotti, I didn’t get to compare that way, but I’ll test.
– user108720
@Pagotti, would be setting a timeSpan and concatenating with the date?
– user108720
Timespan ts = new Timespan(23, 59, 59); (p => p.Dataregistration>= stardate.Date + ts)
– user108720
It may be so but does it outside lambda function
– Pagotti