You will need to get all the records for the client as an array or list, and then filter them using the query you showed while working in the array (instead of LINQ to SQL), or you will have to convert it to syntax that LINQ to SQL can understand :
int thisWeek = (DateTime.Now.DayOfYear + (int)(new DateTime(DateTime.Now.Year, 1, 1).DayOfWeek)) / 7; var queryResult = (from row in result let WeekNum = (row.FollowedUp.Value.DayOfYear + (int)(new DateTime(row.FollowedUp.Value.Year, 1, 1).DayOfWeek)) / 7 where WeekNum == thisWeek select row);
LINQ to SQL is actually smart enough to convert the WeekNum expression into SQL code as follows:
(DATEPART(DayOfYear, [t0].[FollowedUp]) + (CONVERT(Int,(DATEPART(dw, CONVERT(DATETIME, CONVERT(NCHAR(2), 1) + ('/' + (CONVERT(NCHAR(2), 1) + ('/' + CONVERT(NCHAR(4), DATEPART(Year, [t0].[FollowedUp]))))), 101)) + (@@DATEFIRST) + 6) % 7))) / 7
source share