我想返回按某个属性分组的某个实体的列表,按时间戳降序排列并分页(使用 Skip 和 Take)。我得到的是这样的:
container.CoinMessageSet.Where(
c => c.MessageState != MessageStateType.Closed &&
(c.DonorOperator.OperatorCode.Equals("opcode") ||
c.RecipientOperator.OperatorCode.Equals("opcode"))
).OrderByDescending(c => c.TimeStamp)
.GroupBy(c => c.Reference).Skip(x).Take(100);
执行后我得到了异常:
The method 'Skip' is only supported for sorted input in LINQ to Entities.
The method 'OrderBy' must be called before the method 'Skip'.
...我调用了 OrderBy()(尽管是降序),我在 Skip() 之前调用了它!我错过了什么?