我有这个运行良好的 Linq 查询
var test = (from c in context.ConsumptionSet
join pi in context.PropertiesInstanceSet on c.PropertiesInstanceID equals pi.PropertiesInstanceID
join ep in context.EquipmentPropertiesSet on pi.EquipmentPropertiesID equals ep.EquipmentPropertiesID
where (ep.EquipmentID == equipmentId && pi.ProprietesName == ProprietesName.Energy && c.Date <= DateTime.Today && c.Date >= EntityFunctions.AddDays(DateTime.Today, -7))
group c by c.Date.Day into grp
select new
{
test = grp.Key,
value = (from c2 in grp select c2.Value).Max()
}).ToList();
但我想按DayOfWeek
属性对这些结果进行分组,似乎 Linq 不允许这样做,因为当我替换为时出现此group c by c.Date.Day
错误group c by c.Date.DayOfWeek
:
The specified type member 'DayOfWeek' is not supported in LINQ to Entities
这个问题有什么解决方法吗?