s.k.paul
s.k.paul

Reputation: 7311

Skip() and Take() in Entity Framework

I'm trying to load data as follows-

var outletList = (from c in db.OutletList
                  where c.EmployeeId == 1 
                  orderby c.VisitId descending select c).Take(10).Skip(skipQuantity);

int quantity = outletList.Count();    // it's zero

No data is being loaded. I'm new to Entity Framework, so, sorry if it is a foolish question.

Any help?

Upvotes: 3

Views: 9475

Answers (1)

mybirthname
mybirthname

Reputation: 18137

You should first Skip from the whole collection and after that Take.

var outletList = (from c in db.OutletList
                    where c.EmployeeId == 1 
                    orderby c.VisitId descending select c)
                    .Skip(skipQuantity).Take(10);

Upvotes: 9

Related Questions