I am trying to query day of week using linq and I have ms access as the database. Now I have used the following code using % (mod) to check for day of week since linq to query doesn't support DayOfWeek
.
planQuery = planQuery.Where(x => DbFunctions.DiffDays(firstSunday, x.Date) % 7
== (int)DayOfWeek.Monday && x.Date != null);
But the problem occurs when this code is translated to sql it looks like this:
SELECT *
FROM myTable
where (DateDiff("d", [Datum], 1) % 7) = 1
Which in turn throws syntax error when I try to run it because of the %. After looking around I realized % equivalent of ms access is mod
So the following code runs fine. But this is not what the translated SQL look like.
SELECT *
FROM myTable
where (DateDiff("d", [Datum], 1) mod 7) = 1
How can I use linq to query ms access using mod function?