Reputation: 1731
What is the result of ToQueryString when we have time deduction?
TimeSpan t = TimeSpan.FromHours(10); var query = context.table1.Where(x => x.Status == 3 && x.CreatedAt < DateTime.Now - t); var sql = query.ToQueryString();
The result of ToQueryString is not correct IMO. Then what is the correct value?
The output of ToQueryString is
SET @__t_0 = TIME '10:00:00.000000';
SELECT t.Id, t.CreatedAt, t.Status
FROM table1 AS t
WHERE (t.Status = 3) AND (t.CreatedAt < (CURRENT_TIMESTAMP() -
@__t_0));
which makes the time deduction wrong. actually the result of this query is similar to if we wouldn't have 'AND (t.CreatedAt<(CURRENT_TIMESTAMP() - @__t_0))' at all.
But if I run the C# code, it will return a result in which the time deduction is considered and this is telling me that the code that is executed on MySql at the end is different than the result of ToQueryString.
Upvotes: 0
Views: 65