I have a column in my table called Date , and I need to compare this date to WeekOfTheYear with DateTime.Now WeekOfTheYear ,
If I give it like this
var cal = CultureInfo.CurrentCulture.Calendar; int week = cal.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
I get 26 here. Similarly, in my Entity Framework, I need to compare data this week, for this I tried,
entities.WorkingDays.Where(a => cal.GetWeekOfYear(a.DATE,CalendarWeekRule.FirstDay,DayOfWeek.Sunday) == cal.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstDay, DayOfWeek.Sunday)
when I run such a request, I get an error, for example,
"The LINQ to Entities does not recognize the method 'Int32 GetWeekOfYear (System.DateTime, System.Globalization.CalendarWeekRule, System.DayOfWeek)' method, and this method cannot be translated into the storage expression."
How can I get the data for the weekly base here, can anyone help me here ... thanks in advance
source share