I’m receiving an error when trying to query a range of dates from a MS SQL DB in MVC Entity Framework.
Unable to cast the type 'System.Boolean' to type 'System.Data.SqlTypes.SqlBoolean'. LINQ to Entities only supports casting Entity Data Model primitive types.
This is our query:
dbWS.Where(Function(x) x.CountyCode = user.County And x.CompleteStatus.Contains("0") And x.ProgramEffort = 25 And x.combinedDate >= prevDate And x.combinedDate <= tomorrow)
The bold code is causing this error. We were querying this a different way and it worked but since we had to change to a date range we keep getting this error.
We resolved this issue. We had some corrupted data in our DB which had caused us to change a data type in our model to a SqlDateTime from a DateTime. Once we sanitized our data and changed the model back, the problem was resolved.