你会如何在 Linq To Entity 中写这个?
SELECT DATEPART(weekday, MessageBundles.Date) AS WeekDay, count(*) AS Count FROM MessageBundles GROUP BY DATEPART(weekday, MessageBundles.Date)
我试过这样的事情:
for (int day = 1; day <= 7; day = day + 1)
pairs.Add("[" + day + ", " + db.Messages.Count(m => SqlFunctions.DatePart("weekday", m.Date) == day) + "]");
但是它抛出一个异常说“它不能被翻译成存储表达式”(即:SqlFunctions is not supported)