Question:I’m trying to retrieve records from a database in Azure and for the checks I run T-SQL queries directly and then pass them to LINQ against the EF Core context, but I’m running into this problem.
FechaOrientativagreater than or equal to Today, the
Estudiarfield is equal to ‘pt’, I get 2,296 records.
Now in Angular, I do http.Get to my Web API where I execute the following:
Any idea, please?
Answer:Compare both SQL query and EF LINQ query, the difference is:
CAST( GETDATE() AS Date )returns Today Date without time.
EF LINQ –
DateTime.Nowreturns current Date Time.
Hence the queried result will be different
(Example: Only queried records with the date-time field equal/after the query date-time).
From Date and time functions, you are looing for
If you have better answer, please add a comment about this, thank you!