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
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
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.
You can use the Skip method:
db.Products.Where(p => p.Name == "product").Skip(10).Take(10).ToList();
The answer is simple:
db.Products.Where(p => p.Name == "product").Skip(10).Take(10).ToList();