2

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.

4

3 回答 3

7

尝试指定OrderBybefore 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));
于 2013-07-10T08:06:11.743 回答
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));
于 2013-07-10T08:06:26.573 回答
-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.
于 2013-07-10T08:05:25.307 回答