Reputation: 1941
I am Getting an error while executing this query :
The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'.
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));
Actually, I am already using OrderBy
in that query.But, I'm getting the error.
Upvotes: 2
Views: 557
Reputation: 70766
Try specifying OrderBy
before Skip
, like this:
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));
Upvotes: 7
Reputation: 15387
Try this
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.
Upvotes: -1
Reputation: 56716
It tells you exactly what is wrong and what to do about it:
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));
Upvotes: 4