Sk Asraf Sk Asraf - 4 months ago 9x
SQL Question

How to get row numbers 10 to 20 from over 100+ rows using entity framework

I have a table with 100+ rows. I want to get row number 10 to 20 using entity framework, but i can't understand how to write the code

my code is

db.Products.Where(p => p.Name == "product").Take(10, 20).ToList());

but it is showing error.


Use .Skip() and Take()

db.Products.Where(p => p.Name == "product").Skip(10).Take(10).ToList();

^Also the error is Extra ) at the end.

Note *(Suggested by Tim Schmelter & MatBailie) : Order your resultset before paging the rows to avoid arbitrary and unpredictable output.