I am running query in SQL Server and it's running fine and returning data:
var record = DbContext.Attendances
.SqlQuery("select id, checktype, locationinfo, latitude, longitude, employeeid,
activityid, DateNTime at time zone 'utc' at time zone 'pakistan standard time' as datentime " +
"from(select *, CONVERT(varchar, DateNTime at time zone 'utc' at time zone 'pakistan standard time', 101) as tb from dbo.Attendances where EmployeeId = 3) as t "+
"where tb = '03/05/2022'");
Exact same query is not working when I run it in the ASP.NET MVC app using .SqlQuery function. It gave me an error:
The 'DateNTime' property on 'Attendance' could not be set to a 'System.DateTimeOffset' value. You must set this property to a non-null value of type 'System.DateTime'.
Although I set DateNTime non-nulable.
Here is my table:
I cannot change DateTime to DateTime? because then I will have to change the code in many places.
