Hello,
If there is have more than 10 records, then take only 10,
- var query = from a in context.Advertisements where a.idPartner == partnerid select a;
- count = query.Count();
- if (count > 10)
- return (query.Skip(startIndex).Take(10).ToList());
- else
- return query.ToList();
now the error occured,
The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'.
Then I have tried, this code:
- return (query.OrderBy(p=>p.idAdvertisement).Skip(startIndex).Take(10).ToList());
Incorrect syntax near 'OFFSET'.
Invalid usage of the option NEXT in the FETCH statement.
Invalid usage of the option NEXT in the FETCH statement.
How can I solve this ?


Munesh SharmaRank #174 · 13.9K reputationPosted Apr 21, 2017, 2:55 AM EDT
Ramesh PalanivelRank #372 · 6.8K reputationPosted Apr 21, 2017, 2:23 AM EDT
var query = from a in context.Advertisements where a.idPartner == partnerid select a;
count = query.Count();
if (count > 10)
return Queryable.Skip(query,startIndex).Take(10).ToList());
else
return query.ToList();
Abhilash J ARank #1,243 · 1.4K reputationPosted Apr 21, 2017, 2:26 AM EDT
Ramesh PalanivelRank #372 · 6.8K reputationPosted Apr 21, 2017, 2:30 AM EDT
{
DesignationId = des.DESIGNATION_ID,
DesignationCode = des.CODE,
DesignationName = des.NAME
}).ToList();
//List
records.Content = (from desig in designation select desig).Skip((page - 1) * 15)
.Take(15).ToList().AsQueryable
records.TotalRecords = (from designationrecords in _entity.M_DESIGNATION select designationrecords).Count();
records.PageSize = 5;