problems with Linq skip take

c# entity-framework-6 linq

Question

i have this code..

        var documents = from d in db.Documents select d;
        documents = documents.OrderBy(d => d.Created);
        documents = documents.Skip(20).Take(10);

In db i have 25 documents (ids from 1 to 25). When i run this code i get documents from id 19 to 24.

If i write it like this

    documents = documents.Skip(20);

or like this

documents = documents.Skip(20).ToList().Take(10).AsQueryable();

I get documents from id 20 to 25..

What i am missing here??

1
1
3/3/2016 10:49:04 AM

Popular Answer

Your data is not what you think. The problem is the created date in id=25 is not in order.

1
3/3/2016 11:38:52 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow