【发布时间】:2013-07-10 08:02:30
【问题描述】:
执行此查询时出现错误:
“Skip”方法仅支持 LINQ to 中的排序输入 实体。必须在方法之前调用方法“OrderBy” “跳过”。
var data = (from xx in VDC.SURVEY_EMAIL_BLAST
where xx.USER_ID == userid
orderby xx.ID
select xx.TEMPLATE_ID).Distinct().Skip(10).Take(10));
实际上,我已经在那个查询中使用了OrderBy。但是,我得到了错误。
【问题讨论】:
-
我猜你需要一个介于
Distinct()和Skip()之间的OrderBy(...) -
@DonatasK。就在问题中:
The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'. -
现有
orderby无效的原因是Distinct破坏了排序。应该删除现有的orderby。
标签: c# .net sql-server linq sql-order-by