Reputation: 2611
is there any possibility to do this SQL statement in Linq SQL (ASP.NET)
Select * form users limit 23,100
without using another solutions like Loop,For ,....
Thanks for replying.
Upvotes: 0
Views: 981
Reputation: 38638
The methods are Take
and Skip
, for sample:
var result = (from c in Source
select c).Skip(23).Take(100).ToList();
as a good pratice for paging data, you could have some parameters, for sample:
public IEnumerable<Customer> GetCustomers(int pageSize, int pageNumber)
{
var query = from c in customers
select c;
return query.Skip(pageSize * pageNumber)
.Take(pageSize)
.ToList();
}
Upvotes: 6
Reputation: 4808
var usersList = (from users in db.Users
select users).Skip(23).Take(100);
where db
is the datacontext.
should get the answer you want.
You will probably want to use an orderby
clause as there is no guarantee the records returned will be the same order every time.
Upvotes: 2