我希望能够返回一个特定实体按某个属性分组的列表,并按时间戳降序排列并进行分页(使用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()之前也调用了它!我错过了什么?