Sk Asraf Sk Asraf - 1 year ago 85
SQL Question

how can take row number 10 to 20 over 100+ rows using entity framework

i have a table with 100+ rows ,i want to row number 10 to 20 using entity frame work ,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 showing error

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download