我在执行此查询时遇到错误:
方法'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
。但是,我收到了错误。
答案 0 :(得分:6)
尝试在OrderBy
之前指定Skip
,如下所示:
var data = (from xx in VDC.SURVEY_EMAIL_BLAST
where xx.USER_ID == userid
select xx.TEMPLATE_ID).Distinct()
.OrderBy(x => x)
.Skip(10).Take(10));
答案 1 :(得分:4)
它告诉你到底出了什么问题以及怎么做:
var data = (from xx in VDC.SURVEY_EMAIL_BLAST
where xx.USER_ID == userid
orderby xx.ID
select xx.TEMPLATE_ID)
.Distinct()
.OrderBy(x => x)
.Skip(10)
.Take(10));
答案 2 :(得分:-1)
试试这个
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);
data1=data.ToList(); // it will fetch only 11-20.