Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 788
s.k.paul Avatar asked May 09 '26 13:05

s.k.paul


1 Answers

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);
like image 180
mybirthname Avatar answered May 16 '26 17:05

mybirthname



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!